From a242f1a7d50f8c32ff8464e0712a80eabb9c2a9f Mon Sep 17 00:00:00 2001 From: Kristen Maevyn Date: Thu, 6 Jun 2024 09:48:10 -0400 Subject: [PATCH 1/3] Add decorator behavioral tests --- src/decorator/README.md | 82 ++++++++++++++ .../accessor-deco-invalid-return-get.case | 22 ++++ .../accessor-deco-invalid-return-init.case | 22 ++++ .../accessor-deco-invalid-return-set.case | 22 ++++ .../accessor-deco-invalid-return.case | 20 ++++ src/decorator/accessor-deco-returns-get.case | 25 +++++ src/decorator/accessor-deco-returns-init.case | 27 +++++ src/decorator/accessor-deco-returns-set.case | 27 +++++ .../accessor-with-init-deco-returns-get.case | 28 +++++ .../accessor-with-init-deco-returns-init.case | 30 ++++++ .../accessor-with-init-deco-returns-set.case | 30 ++++++ .../error/private/instance/cls-decl.template | 20 ++++ .../error/private/instance/cls-expr.template | 21 ++++ .../error/private/static/cls-decl.template | 21 ++++ .../error/private/static/cls-expr.template | 20 ++++ .../error/public/instance/cls-decl.template | 21 ++++ .../error/public/instance/cls-expr.template | 21 ++++ .../error/public/static/cls-decl.template | 21 ++++ .../error/public/static/cls-expr.template | 20 ++++ .../private/instance/cls-decl.template | 28 +++++ .../private/instance/cls-expr.template | 28 +++++ .../standard/private/static/cls-decl.template | 28 +++++ .../standard/private/static/cls-expr.template | 28 +++++ .../public/instance/cls-decl.template | 28 +++++ .../public/instance/cls-expr.template | 28 +++++ .../standard/public/static/cls-decl.template | 28 +++++ .../standard/public/static/cls-expr.template | 28 +++++ .../private/instance/cls-decl.template | 28 +++++ .../private/instance/cls-expr.template | 28 +++++ .../private/static/cls-decl.template | 28 +++++ .../private/static/cls-expr.template | 28 +++++ .../public/instance/cls-decl.template | 28 +++++ .../public/instance/cls-expr.template | 28 +++++ .../with-init/public/static/cls-decl.template | 28 +++++ .../with-init/public/static/cls-expr.template | 28 +++++ .../class-deco-invalid-return-arrow.case | 20 ++++ .../class-deco-invalid-return-primitive.case | 20 ++++ .../class-deco-rebinds-identifier.case | 32 ++++++ src/decorator/class-deco-returns-class.case | 33 ++++++ .../class-deco-returns-function.case | 23 ++++ src/decorator/class-deco-returns-proxy.case | 31 ++++++ .../class-deco-returns-subclass.case | 34 ++++++ src/decorator/class/error/cls-decl.template | 18 ++++ src/decorator/class/error/cls-expr.template | 21 ++++ .../class/standard/cls-decl.template | 18 ++++ .../class/standard/cls-expr.template | 17 +++ .../class/with-super-class/cls-decl.template | 20 ++++ .../class/with-super-class/cls-expr.template | 19 ++++ src/decorator/context-access-get.case | 33 ++++++ src/decorator/context-access-set.case | 31 ++++++ src/decorator/context-kind-accessor.case | 17 +++ src/decorator/context-kind-class.case | 17 +++ src/decorator/context-kind-field.case | 17 +++ src/decorator/context-kind-getter.case | 17 +++ src/decorator/context-kind-method.case | 20 ++++ src/decorator/context-kind-setter.case | 17 +++ src/decorator/context-name-class.case | 17 +++ src/decorator/context-name-private.case | 22 ++++ src/decorator/context-name-public.case | 22 ++++ src/decorator/context-private-false.case | 22 ++++ src/decorator/context-private-true.case | 22 ++++ src/decorator/context-static-false.case | 27 +++++ src/decorator/context-static-true.case | 27 +++++ ...-order-application-field-and-accessor.case | 42 ++++++++ ...or-order-application-method-and-class.case | 31 ++++++ ...corator-order-phases-1-pre-definition.case | 72 +++++++++++++ .../decorator-order-phases-2-application.case | 78 ++++++++++++++ .../decorator-order-phases-3-init-static.case | 101 ++++++++++++++++++ ...ecorator-order-phases-4-init-instance.case | 84 +++++++++++++++ src/decorator/decorator-order-phases.case | 74 +++++++++++++ .../field-and-accessor-init-this.case | 33 ++++++ src/decorator/field-deco-invalid-return.case | 20 ++++ .../field-deco-returns-initializer.case | 23 ++++ .../field-deco-returns-undefined.case | 20 ++++ src/decorator/field-receives-undefined.case | 22 ++++ ...ld-with-init-deco-returns-initializer.case | 31 ++++++ ...ield-with-init-deco-returns-undefined.case | 28 +++++ .../error/private/instance/cls-decl.template | 20 ++++ .../error/private/instance/cls-expr.template | 21 ++++ .../error/private/static/cls-decl.template | 21 ++++ .../error/private/static/cls-expr.template | 20 ++++ .../error/public/instance/cls-decl.template | 21 ++++ .../error/public/instance/cls-expr.template | 21 ++++ .../error/public/static/cls-decl.template | 21 ++++ .../error/public/static/cls-expr.template | 20 ++++ .../private/instance/cls-decl.template | 28 +++++ .../private/instance/cls-expr.template | 28 +++++ .../standard/private/static/cls-decl.template | 28 +++++ .../standard/private/static/cls-expr.template | 28 +++++ .../public/instance/cls-decl.template | 28 +++++ .../public/instance/cls-expr.template | 28 +++++ .../standard/public/static/cls-decl.template | 28 +++++ .../standard/public/static/cls-expr.template | 28 +++++ .../private/instance/cls-decl.template | 28 +++++ .../private/instance/cls-expr.template | 28 +++++ .../private/static/cls-decl.template | 28 +++++ .../private/static/cls-expr.template | 28 +++++ .../public/instance/cls-decl.template | 28 +++++ .../public/instance/cls-expr.template | 28 +++++ .../with-init/public/static/cls-decl.template | 28 +++++ .../with-init/public/static/cls-expr.template | 28 +++++ .../getter-deco-returns-invalid.case | 20 ++++ .../getter-deco-returns-replacement.case | 25 +++++ .../getter-deco-returns-undefined.case | 26 +++++ .../error/private/instance/cls-decl.template | 20 ++++ .../error/private/instance/cls-expr.template | 21 ++++ .../error/private/static/cls-decl.template | 21 ++++ .../error/private/static/cls-expr.template | 20 ++++ .../error/public/instance/cls-decl.template | 21 ++++ .../error/public/instance/cls-expr.template | 21 ++++ .../error/public/static/cls-decl.template | 21 ++++ .../error/public/static/cls-expr.template | 20 ++++ .../private/instance/cls-decl.template | 28 +++++ .../private/instance/cls-expr.template | 28 +++++ .../standard/private/static/cls-decl.template | 28 +++++ .../standard/private/static/cls-expr.template | 28 +++++ .../public/instance/cls-decl.template | 29 +++++ .../public/instance/cls-expr.template | 28 +++++ .../standard/public/static/cls-decl.template | 28 +++++ .../standard/public/static/cls-expr.template | 28 +++++ ...method-async-deco-returns-replacement.case | 22 ++++ .../method-async-deco-returns-undefined.case | 26 +++++ .../method-deco-returns-invalid.case | 20 ++++ .../method-deco-returns-replacement.case | 22 ++++ .../method-deco-returns-undefined.case | 26 +++++ ...od-generator-deco-returns-replacement.case | 22 ++++ ...thod-generator-deco-returns-undefined.case | 26 +++++ .../async/private/instance/cls-decl.template | 26 +++++ .../async/private/instance/cls-expr.template | 26 +++++ .../async/private/static/cls-decl.template | 26 +++++ .../async/private/static/cls-expr.template | 26 +++++ .../async/public/instance/cls-decl.template | 27 +++++ .../async/public/instance/cls-expr.template | 26 +++++ .../async/public/static/cls-decl.template | 26 +++++ .../async/public/static/cls-expr.template | 26 +++++ .../error/private/instance/cls-decl.template | 20 ++++ .../error/private/instance/cls-expr.template | 21 ++++ .../error/private/static/cls-decl.template | 21 ++++ .../error/private/static/cls-expr.template | 20 ++++ .../error/public/instance/cls-decl.template | 21 ++++ .../error/public/instance/cls-expr.template | 21 ++++ .../error/public/static/cls-decl.template | 21 ++++ .../error/public/static/cls-expr.template | 20 ++++ .../private/instance/cls-decl.template | 26 +++++ .../private/instance/cls-expr.template | 26 +++++ .../private/static/cls-decl.template | 26 +++++ .../private/static/cls-expr.template | 26 +++++ .../public/instance/cls-decl.template | 27 +++++ .../public/instance/cls-expr.template | 26 +++++ .../generator/public/static/cls-decl.template | 26 +++++ .../generator/public/static/cls-expr.template | 26 +++++ .../private/instance/cls-decl.template | 26 +++++ .../private/instance/cls-expr.template | 26 +++++ .../standard/private/static/cls-decl.template | 26 +++++ .../standard/private/static/cls-expr.template | 26 +++++ .../public/instance/cls-decl.template | 27 +++++ .../public/instance/cls-expr.template | 26 +++++ .../standard/public/static/cls-decl.template | 26 +++++ .../standard/public/static/cls-expr.template | 26 +++++ .../setter-deco-returns-invalid.case | 20 ++++ .../setter-deco-returns-replacement.case | 25 +++++ .../setter-deco-returns-undefined.case | 31 ++++++ .../error/private/instance/cls-decl.template | 20 ++++ .../error/private/instance/cls-expr.template | 21 ++++ .../error/private/static/cls-decl.template | 21 ++++ .../error/private/static/cls-expr.template | 20 ++++ .../error/public/instance/cls-decl.template | 21 ++++ .../error/public/instance/cls-expr.template | 21 ++++ .../error/public/static/cls-decl.template | 21 ++++ .../error/public/static/cls-expr.template | 20 ++++ .../private/instance/cls-decl.template | 31 ++++++ .../private/instance/cls-expr.template | 31 ++++++ .../standard/private/static/cls-decl.template | 31 ++++++ .../standard/private/static/cls-expr.template | 31 ++++++ .../public/instance/cls-decl.template | 32 ++++++ .../public/instance/cls-expr.template | 31 ++++++ .../standard/public/static/cls-decl.template | 31 ++++++ .../standard/public/static/cls-expr.template | 31 ++++++ 178 files changed, 4761 insertions(+) create mode 100644 src/decorator/README.md create mode 100644 src/decorator/accessor-deco-invalid-return-get.case create mode 100644 src/decorator/accessor-deco-invalid-return-init.case create mode 100644 src/decorator/accessor-deco-invalid-return-set.case create mode 100644 src/decorator/accessor-deco-invalid-return.case create mode 100644 src/decorator/accessor-deco-returns-get.case create mode 100644 src/decorator/accessor-deco-returns-init.case create mode 100644 src/decorator/accessor-deco-returns-set.case create mode 100644 src/decorator/accessor-with-init-deco-returns-get.case create mode 100644 src/decorator/accessor-with-init-deco-returns-init.case create mode 100644 src/decorator/accessor-with-init-deco-returns-set.case create mode 100644 src/decorator/accessors/error/private/instance/cls-decl.template create mode 100644 src/decorator/accessors/error/private/instance/cls-expr.template create mode 100644 src/decorator/accessors/error/private/static/cls-decl.template create mode 100644 src/decorator/accessors/error/private/static/cls-expr.template create mode 100644 src/decorator/accessors/error/public/instance/cls-decl.template create mode 100644 src/decorator/accessors/error/public/instance/cls-expr.template create mode 100644 src/decorator/accessors/error/public/static/cls-decl.template create mode 100644 src/decorator/accessors/error/public/static/cls-expr.template create mode 100644 src/decorator/accessors/standard/private/instance/cls-decl.template create mode 100644 src/decorator/accessors/standard/private/instance/cls-expr.template create mode 100644 src/decorator/accessors/standard/private/static/cls-decl.template create mode 100644 src/decorator/accessors/standard/private/static/cls-expr.template create mode 100644 src/decorator/accessors/standard/public/instance/cls-decl.template create mode 100644 src/decorator/accessors/standard/public/instance/cls-expr.template create mode 100644 src/decorator/accessors/standard/public/static/cls-decl.template create mode 100644 src/decorator/accessors/standard/public/static/cls-expr.template create mode 100644 src/decorator/accessors/with-init/private/instance/cls-decl.template create mode 100644 src/decorator/accessors/with-init/private/instance/cls-expr.template create mode 100644 src/decorator/accessors/with-init/private/static/cls-decl.template create mode 100644 src/decorator/accessors/with-init/private/static/cls-expr.template create mode 100644 src/decorator/accessors/with-init/public/instance/cls-decl.template create mode 100644 src/decorator/accessors/with-init/public/instance/cls-expr.template create mode 100644 src/decorator/accessors/with-init/public/static/cls-decl.template create mode 100644 src/decorator/accessors/with-init/public/static/cls-expr.template create mode 100644 src/decorator/class-deco-invalid-return-arrow.case create mode 100644 src/decorator/class-deco-invalid-return-primitive.case create mode 100644 src/decorator/class-deco-rebinds-identifier.case create mode 100644 src/decorator/class-deco-returns-class.case create mode 100644 src/decorator/class-deco-returns-function.case create mode 100644 src/decorator/class-deco-returns-proxy.case create mode 100644 src/decorator/class-deco-returns-subclass.case create mode 100644 src/decorator/class/error/cls-decl.template create mode 100644 src/decorator/class/error/cls-expr.template create mode 100644 src/decorator/class/standard/cls-decl.template create mode 100644 src/decorator/class/standard/cls-expr.template create mode 100644 src/decorator/class/with-super-class/cls-decl.template create mode 100644 src/decorator/class/with-super-class/cls-expr.template create mode 100644 src/decorator/context-access-get.case create mode 100644 src/decorator/context-access-set.case create mode 100644 src/decorator/context-kind-accessor.case create mode 100644 src/decorator/context-kind-class.case create mode 100644 src/decorator/context-kind-field.case create mode 100644 src/decorator/context-kind-getter.case create mode 100644 src/decorator/context-kind-method.case create mode 100644 src/decorator/context-kind-setter.case create mode 100644 src/decorator/context-name-class.case create mode 100644 src/decorator/context-name-private.case create mode 100644 src/decorator/context-name-public.case create mode 100644 src/decorator/context-private-false.case create mode 100644 src/decorator/context-private-true.case create mode 100644 src/decorator/context-static-false.case create mode 100644 src/decorator/context-static-true.case create mode 100644 src/decorator/decorator-order-application-field-and-accessor.case create mode 100644 src/decorator/decorator-order-application-method-and-class.case create mode 100644 src/decorator/decorator-order-phases-1-pre-definition.case create mode 100644 src/decorator/decorator-order-phases-2-application.case create mode 100644 src/decorator/decorator-order-phases-3-init-static.case create mode 100644 src/decorator/decorator-order-phases-4-init-instance.case create mode 100644 src/decorator/decorator-order-phases.case create mode 100644 src/decorator/field-and-accessor-init-this.case create mode 100644 src/decorator/field-deco-invalid-return.case create mode 100644 src/decorator/field-deco-returns-initializer.case create mode 100644 src/decorator/field-deco-returns-undefined.case create mode 100644 src/decorator/field-receives-undefined.case create mode 100644 src/decorator/field-with-init-deco-returns-initializer.case create mode 100644 src/decorator/field-with-init-deco-returns-undefined.case create mode 100644 src/decorator/fields/error/private/instance/cls-decl.template create mode 100644 src/decorator/fields/error/private/instance/cls-expr.template create mode 100644 src/decorator/fields/error/private/static/cls-decl.template create mode 100644 src/decorator/fields/error/private/static/cls-expr.template create mode 100644 src/decorator/fields/error/public/instance/cls-decl.template create mode 100644 src/decorator/fields/error/public/instance/cls-expr.template create mode 100644 src/decorator/fields/error/public/static/cls-decl.template create mode 100644 src/decorator/fields/error/public/static/cls-expr.template create mode 100644 src/decorator/fields/standard/private/instance/cls-decl.template create mode 100644 src/decorator/fields/standard/private/instance/cls-expr.template create mode 100644 src/decorator/fields/standard/private/static/cls-decl.template create mode 100644 src/decorator/fields/standard/private/static/cls-expr.template create mode 100644 src/decorator/fields/standard/public/instance/cls-decl.template create mode 100644 src/decorator/fields/standard/public/instance/cls-expr.template create mode 100644 src/decorator/fields/standard/public/static/cls-decl.template create mode 100644 src/decorator/fields/standard/public/static/cls-expr.template create mode 100644 src/decorator/fields/with-init/private/instance/cls-decl.template create mode 100644 src/decorator/fields/with-init/private/instance/cls-expr.template create mode 100644 src/decorator/fields/with-init/private/static/cls-decl.template create mode 100644 src/decorator/fields/with-init/private/static/cls-expr.template create mode 100644 src/decorator/fields/with-init/public/instance/cls-decl.template create mode 100644 src/decorator/fields/with-init/public/instance/cls-expr.template create mode 100644 src/decorator/fields/with-init/public/static/cls-decl.template create mode 100644 src/decorator/fields/with-init/public/static/cls-expr.template create mode 100644 src/decorator/getter-deco-returns-invalid.case create mode 100644 src/decorator/getter-deco-returns-replacement.case create mode 100644 src/decorator/getter-deco-returns-undefined.case create mode 100644 src/decorator/getters/error/private/instance/cls-decl.template create mode 100644 src/decorator/getters/error/private/instance/cls-expr.template create mode 100644 src/decorator/getters/error/private/static/cls-decl.template create mode 100644 src/decorator/getters/error/private/static/cls-expr.template create mode 100644 src/decorator/getters/error/public/instance/cls-decl.template create mode 100644 src/decorator/getters/error/public/instance/cls-expr.template create mode 100644 src/decorator/getters/error/public/static/cls-decl.template create mode 100644 src/decorator/getters/error/public/static/cls-expr.template create mode 100644 src/decorator/getters/standard/private/instance/cls-decl.template create mode 100644 src/decorator/getters/standard/private/instance/cls-expr.template create mode 100644 src/decorator/getters/standard/private/static/cls-decl.template create mode 100644 src/decorator/getters/standard/private/static/cls-expr.template create mode 100644 src/decorator/getters/standard/public/instance/cls-decl.template create mode 100644 src/decorator/getters/standard/public/instance/cls-expr.template create mode 100644 src/decorator/getters/standard/public/static/cls-decl.template create mode 100644 src/decorator/getters/standard/public/static/cls-expr.template create mode 100644 src/decorator/method-async-deco-returns-replacement.case create mode 100644 src/decorator/method-async-deco-returns-undefined.case create mode 100644 src/decorator/method-deco-returns-invalid.case create mode 100644 src/decorator/method-deco-returns-replacement.case create mode 100644 src/decorator/method-deco-returns-undefined.case create mode 100644 src/decorator/method-generator-deco-returns-replacement.case create mode 100644 src/decorator/method-generator-deco-returns-undefined.case create mode 100644 src/decorator/methods/async/private/instance/cls-decl.template create mode 100644 src/decorator/methods/async/private/instance/cls-expr.template create mode 100644 src/decorator/methods/async/private/static/cls-decl.template create mode 100644 src/decorator/methods/async/private/static/cls-expr.template create mode 100644 src/decorator/methods/async/public/instance/cls-decl.template create mode 100644 src/decorator/methods/async/public/instance/cls-expr.template create mode 100644 src/decorator/methods/async/public/static/cls-decl.template create mode 100644 src/decorator/methods/async/public/static/cls-expr.template create mode 100644 src/decorator/methods/error/private/instance/cls-decl.template create mode 100644 src/decorator/methods/error/private/instance/cls-expr.template create mode 100644 src/decorator/methods/error/private/static/cls-decl.template create mode 100644 src/decorator/methods/error/private/static/cls-expr.template create mode 100644 src/decorator/methods/error/public/instance/cls-decl.template create mode 100644 src/decorator/methods/error/public/instance/cls-expr.template create mode 100644 src/decorator/methods/error/public/static/cls-decl.template create mode 100644 src/decorator/methods/error/public/static/cls-expr.template create mode 100644 src/decorator/methods/generator/private/instance/cls-decl.template create mode 100644 src/decorator/methods/generator/private/instance/cls-expr.template create mode 100644 src/decorator/methods/generator/private/static/cls-decl.template create mode 100644 src/decorator/methods/generator/private/static/cls-expr.template create mode 100644 src/decorator/methods/generator/public/instance/cls-decl.template create mode 100644 src/decorator/methods/generator/public/instance/cls-expr.template create mode 100644 src/decorator/methods/generator/public/static/cls-decl.template create mode 100644 src/decorator/methods/generator/public/static/cls-expr.template create mode 100644 src/decorator/methods/standard/private/instance/cls-decl.template create mode 100644 src/decorator/methods/standard/private/instance/cls-expr.template create mode 100644 src/decorator/methods/standard/private/static/cls-decl.template create mode 100644 src/decorator/methods/standard/private/static/cls-expr.template create mode 100644 src/decorator/methods/standard/public/instance/cls-decl.template create mode 100644 src/decorator/methods/standard/public/instance/cls-expr.template create mode 100644 src/decorator/methods/standard/public/static/cls-decl.template create mode 100644 src/decorator/methods/standard/public/static/cls-expr.template create mode 100644 src/decorator/setter-deco-returns-invalid.case create mode 100644 src/decorator/setter-deco-returns-replacement.case create mode 100644 src/decorator/setter-deco-returns-undefined.case create mode 100644 src/decorator/setters/error/private/instance/cls-decl.template create mode 100644 src/decorator/setters/error/private/instance/cls-expr.template create mode 100644 src/decorator/setters/error/private/static/cls-decl.template create mode 100644 src/decorator/setters/error/private/static/cls-expr.template create mode 100644 src/decorator/setters/error/public/instance/cls-decl.template create mode 100644 src/decorator/setters/error/public/instance/cls-expr.template create mode 100644 src/decorator/setters/error/public/static/cls-decl.template create mode 100644 src/decorator/setters/error/public/static/cls-expr.template create mode 100644 src/decorator/setters/standard/private/instance/cls-decl.template create mode 100644 src/decorator/setters/standard/private/instance/cls-expr.template create mode 100644 src/decorator/setters/standard/private/static/cls-decl.template create mode 100644 src/decorator/setters/standard/private/static/cls-expr.template create mode 100644 src/decorator/setters/standard/public/instance/cls-decl.template create mode 100644 src/decorator/setters/standard/public/instance/cls-expr.template create mode 100644 src/decorator/setters/standard/public/static/cls-decl.template create mode 100644 src/decorator/setters/standard/public/static/cls-expr.template diff --git a/src/decorator/README.md b/src/decorator/README.md new file mode 100644 index 00000000000..cfcec6b95ac --- /dev/null +++ b/src/decorator/README.md @@ -0,0 +1,82 @@ +# Decorator Test Notes + +## Terminology + +Some terms are simplified in these tests to make it easier to communicate +meaning and intent. + +- **static** is used to refer to all class elements that are used with the + `static` keyword, including fields and methods. This should be thought of as + "elements that belong to the class definition". + +- **instance** is used to refer to all class elements that are used _without_ + the static keyword, including fields and methods. This should be thought as + "elements that belong to the class instance". Some of these elements are + assigned to the class prototype rather than the instance, but from a typical + usage perspective, a user will only call these methods when dealing with an + instance of the class. Most users do not ever deal directly with the class + prototype. + +- **methods** refers to all public/private _methods_, _getters_, and _setters_. + These are elements that do _not_ have a per-instance initializer, and for this + reason they are grouped together for things like initialization and decorator + application. + +- **fields** refers to all public/private _fields_ and _accessors_. Accessors + here refers to auto-accessors created with the `accessor` keyword, _NOT_ + getters and setters created with the `get` and `set` keywords. These are + elements that _have_ an initialization step per-instance, and grouped + together for initialization and decorator application for that reason. + +- **Extra-initializers** refers to all initializers added via + `context.addInitializer`. This distinguishes them from standard initializers + for fields and accessors, which run in a different order and with different + timing. + +## Structure + +- Element decorator templates all follow the same basic structure in order to + share as much code as possible for repeated tests. + + - The class element being tested is named `element` for public elements and + `#element` for private elements. + + - If the element is gettable, there is a `getElement` public method that + directly gets the element. If the element is a field, accessor, or getter, + this will call any getters and return the value. If it is a method, it will + return the method itself. Setters are not gettable. + + - These is a `setElement` public method that directly sets the element. If the + element is a field, accessor, or setter, this will call any setters and set + the value. Getters and methods are not settable. + +- Each element template folder is broken down into the following directory + structure: + + ``` + . + └── [element type]/ + └── [test case type]/ + ├── private/ + │ ├── instance/ + │ │ ├── cls-decl.template + │ │ └── cls-expr.template + │ └── static/ + │ ├── cls-decl.template + │ └── cls-expr.template + └── public/ + ├── instance/ + │ ├── cls-decl.template + │ └── cls-expr.template + └── static/ + └── cls-decl.template/ + └── cls-expr.template + ``` + + This structure allows each test to easily select the types of values it + applies to and test them across both class declarations and expressions. + Private and public are split out because there are some common differences + between them (e.g. `context.private`, `context.name`) and the same is true for + static vs instance (e.g. `context.static`). + + diff --git a/src/decorator/accessor-deco-invalid-return-get.case b/src/decorator/accessor-deco-invalid-return-get.case new file mode 100644 index 00000000000..9aeb0987d9e --- /dev/null +++ b/src/decorator/accessor-deco-invalid-return-get.case @@ -0,0 +1,22 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-applydecoratorstoelementdefinition +desc: Accessor decorator cannot return invalid getter +template: accessors/error/**/* +features: [decorators] +---*/ + +//- decorators +function dec() { + return { + get: 123 + }; +} + +//- application +@dec + +//- error +TypeError diff --git a/src/decorator/accessor-deco-invalid-return-init.case b/src/decorator/accessor-deco-invalid-return-init.case new file mode 100644 index 00000000000..3986808be56 --- /dev/null +++ b/src/decorator/accessor-deco-invalid-return-init.case @@ -0,0 +1,22 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-applydecoratorstoelementdefinition +desc: Accessor decorator cannot return invalid init +template: accessors/error/**/* +features: [decorators] +---*/ + +//- decorators +function dec() { + return { + init: 123 + }; +} + +//- application +@dec + +//- error +TypeError diff --git a/src/decorator/accessor-deco-invalid-return-set.case b/src/decorator/accessor-deco-invalid-return-set.case new file mode 100644 index 00000000000..8c3b0a300c3 --- /dev/null +++ b/src/decorator/accessor-deco-invalid-return-set.case @@ -0,0 +1,22 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-applydecoratorstoelementdefinition +desc: Accessor decorator cannot return invalid setter +template: accessors/error/**/* +features: [decorators] +---*/ + +//- decorators +function dec() { + return { + set: 123 + }; +} + +//- application +@dec + +//- error +TypeError diff --git a/src/decorator/accessor-deco-invalid-return.case b/src/decorator/accessor-deco-invalid-return.case new file mode 100644 index 00000000000..86dc47e2023 --- /dev/null +++ b/src/decorator/accessor-deco-invalid-return.case @@ -0,0 +1,20 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-applydecoratorstoelementdefinition +desc: Accessor decorator cannot return invalid init +template: accessors/error/**/* +features: [decorators] +---*/ + +//- decorators +function dec() { + return 123; +} + +//- application +@dec + +//- error +TypeError diff --git a/src/decorator/accessor-deco-returns-get.case b/src/decorator/accessor-deco-returns-get.case new file mode 100644 index 00000000000..7bb02efeb0e --- /dev/null +++ b/src/decorator/accessor-deco-returns-get.case @@ -0,0 +1,25 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-applydecoratorstoelementdefinition +desc: Accessor decorator can return a new getter +template: accessors/standard/**/* +features: [decorators] +---*/ + +//- decorators +function dec({ get }) { + return { + get() { + assert.sameValue(get.call(this), undefined); + return 123; + } + }; +} + +//- application +@dec + +//- assertions +assert.sameValue(classOrInstance.getElement(), 123); diff --git a/src/decorator/accessor-deco-returns-init.case b/src/decorator/accessor-deco-returns-init.case new file mode 100644 index 00000000000..27a1966daa0 --- /dev/null +++ b/src/decorator/accessor-deco-returns-init.case @@ -0,0 +1,27 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-applydecoratorstoelementdefinition +desc: Accessor decorator can return a new init +template: accessors/standard/**/* +features: [decorators] +---*/ + +//- decorators +function dec() { + return { + init(value) { + assert.sameValue(value, undefined); + return 123; + } + }; +} + +//- application +@dec + +//- assertions +assert.sameValue(classOrInstance.getElement(), 123); +classOrInstance.setElement(456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/src/decorator/accessor-deco-returns-set.case b/src/decorator/accessor-deco-returns-set.case new file mode 100644 index 00000000000..7447e9def8c --- /dev/null +++ b/src/decorator/accessor-deco-returns-set.case @@ -0,0 +1,27 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-applydecoratorstoelementdefinition +desc: Accessor decorator can return a new getter +template: accessors/standard/**/* +features: [decorators] +---*/ + +//- decorators +function dec({ set }) { + return { + set(value) { + assert.sameValue(value, 123); + set.call(this, 456); + } + }; +} + +//- application +@dec + +//- assertions +assert.sameValue(classOrInstance.getElement(), undefined); +classOrInstance.setElement(123); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/src/decorator/accessor-with-init-deco-returns-get.case b/src/decorator/accessor-with-init-deco-returns-get.case new file mode 100644 index 00000000000..13ab031c827 --- /dev/null +++ b/src/decorator/accessor-with-init-deco-returns-get.case @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-applydecoratorstoelementdefinition +desc: Accessor decorator can return a new getter +template: accessors/with-init/**/* +features: [decorators] +---*/ + +//- initializer +123 + +//- decorators +function dec({ get }) { + return { + get() { + assert.sameValue(get.call(this), 123); + return 456; + } + }; +} + +//- application +@dec + +//- assertions +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/src/decorator/accessor-with-init-deco-returns-init.case b/src/decorator/accessor-with-init-deco-returns-init.case new file mode 100644 index 00000000000..1c7b07338f5 --- /dev/null +++ b/src/decorator/accessor-with-init-deco-returns-init.case @@ -0,0 +1,30 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-applydecoratorstoelementdefinition +desc: Accessor decorator can return a new init that chains with default initializer +template: accessors/with-init/**/* +features: [decorators] +---*/ + +//- initializer +123 + +//- decorators +function dec({ get, set }) { + return { + init(value) { + assert.sameValue(value, 123); + return 456; + } + }; +} + +//- application +@dec + +//- assertions +assert.sameValue(classOrInstance.getElement(), 456); +classOrInstance.setElement(789); +assert.sameValue(classOrInstance.getElement(), 789); diff --git a/src/decorator/accessor-with-init-deco-returns-set.case b/src/decorator/accessor-with-init-deco-returns-set.case new file mode 100644 index 00000000000..dc484f0fc6c --- /dev/null +++ b/src/decorator/accessor-with-init-deco-returns-set.case @@ -0,0 +1,30 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-applydecoratorstoelementdefinition +desc: Accessor decorator can return a new setter when initializer is present +template: accessors/with-init/**/* +features: [decorators] +---*/ + +//- initializer +123 + +//- decorators +function dec({ set }) { + return { + set(value) { + assert.sameValue(value, 456); + set.call(this, 789); + } + }; +} + +//- application +@dec + +//- assertions +assert.sameValue(classOrInstance.getElement(), 123); +classOrInstance.setElement(456); +assert.sameValue(classOrInstance.getElement(), 789); diff --git a/src/decorator/accessors/error/private/instance/cls-decl.template b/src/decorator/accessors/error/private/instance/cls-decl.template new file mode 100644 index 00000000000..466f34b0fa1 --- /dev/null +++ b/src/decorator/accessors/error/private/instance/cls-decl.template @@ -0,0 +1,20 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/accessor/error/private/instance/ +name: private acessor decorator evaluation error in class declaration +features: [class, decorators, class-fields-private] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +function evaluate() { + class C { + /*{ application }*/ + accessor #element; + } +} + +assert.throws(/*{ error }*/, evaluate); diff --git a/src/decorator/accessors/error/private/instance/cls-expr.template b/src/decorator/accessors/error/private/instance/cls-expr.template new file mode 100644 index 00000000000..2963f6dc5be --- /dev/null +++ b/src/decorator/accessors/error/private/instance/cls-expr.template @@ -0,0 +1,21 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/accessor/error/private/instance/ +name: private acessor decorator behavior in class expression +features: [class, decorators, class-fields-private] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +function evaluate() { + var C = class { + /*{ application }*/ + accessor #element; + } +} + +assert.throws(/*{ error }*/, evaluate); + diff --git a/src/decorator/accessors/error/private/static/cls-decl.template b/src/decorator/accessors/error/private/static/cls-decl.template new file mode 100644 index 00000000000..4746e010eca --- /dev/null +++ b/src/decorator/accessors/error/private/static/cls-decl.template @@ -0,0 +1,21 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/accessor/error/private/static/ +name: private static acessor decorator behavior in class declaration +features: [class, decorators, class-static-fields-private] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +function evaluate() { + class C { + /*{ application }*/ + static accessor #element; + } +} + +assert.throws(/*{ error }*/, evaluate); + diff --git a/src/decorator/accessors/error/private/static/cls-expr.template b/src/decorator/accessors/error/private/static/cls-expr.template new file mode 100644 index 00000000000..532086f4029 --- /dev/null +++ b/src/decorator/accessors/error/private/static/cls-expr.template @@ -0,0 +1,20 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/accessor/error/private/static/ +name: private static acessor decorator behavior in class expression +features: [class, decorators, class-static-fields-private] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +function evaluate() { + var C = class { + /*{ application }*/ + static accessor #element; + } +} + +assert.throws(/*{ error }*/, evaluate); diff --git a/src/decorator/accessors/error/public/instance/cls-decl.template b/src/decorator/accessors/error/public/instance/cls-decl.template new file mode 100644 index 00000000000..be846c60f93 --- /dev/null +++ b/src/decorator/accessors/error/public/instance/cls-decl.template @@ -0,0 +1,21 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/accessor/error/public/instance/ +name: public acessor decorator behavior in class declaration +features: [class, decorators, class-fields-public] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +function evaluate() { + class C { + /*{ application }*/ + accessor element; + } +} + +assert.throws(/*{ error }*/, evaluate); + diff --git a/src/decorator/accessors/error/public/instance/cls-expr.template b/src/decorator/accessors/error/public/instance/cls-expr.template new file mode 100644 index 00000000000..34be9688a11 --- /dev/null +++ b/src/decorator/accessors/error/public/instance/cls-expr.template @@ -0,0 +1,21 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/accessor/error/public/instance/ +name: public acessor decorator behavior in class expression +features: [class, decorators, class-fields-public] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +function evaluate() { + var C = class { + /*{ application }*/ + accessor element; + } +} + +assert.throws(/*{ error }*/, evaluate); + diff --git a/src/decorator/accessors/error/public/static/cls-decl.template b/src/decorator/accessors/error/public/static/cls-decl.template new file mode 100644 index 00000000000..fc6d7bf0a5d --- /dev/null +++ b/src/decorator/accessors/error/public/static/cls-decl.template @@ -0,0 +1,21 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/accessor/public/static/ +name: public static acessor decorator behavior in class declaration +features: [class, decorators, class-static-fields-public] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +function evaluate() { + class C { + /*{ application }*/ + static accessor element; + } +} + +assert.throws(/*{ error }*/, evaluate); + diff --git a/src/decorator/accessors/error/public/static/cls-expr.template b/src/decorator/accessors/error/public/static/cls-expr.template new file mode 100644 index 00000000000..00799950155 --- /dev/null +++ b/src/decorator/accessors/error/public/static/cls-expr.template @@ -0,0 +1,20 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/accessor/public/static/ +name: public static acessor decorator behavior in class expression +features: [class, decorators, class-static-fields-public] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +function evaluate() { + var C = class { + /*{ application }*/ + static accessor element; + } +} + +assert.throws(/*{ error }*/, evaluate); diff --git a/src/decorator/accessors/standard/private/instance/cls-decl.template b/src/decorator/accessors/standard/private/instance/cls-decl.template new file mode 100644 index 00000000000..8606f0d138b --- /dev/null +++ b/src/decorator/accessors/standard/private/instance/cls-decl.template @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/accessor/private/instance/ +name: private acessor decorator behavior in class declaration +features: [class, decorators, class-fields-private] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +class C { + /*{ application }*/ + accessor #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +/*{ assertions }*/ diff --git a/src/decorator/accessors/standard/private/instance/cls-expr.template b/src/decorator/accessors/standard/private/instance/cls-expr.template new file mode 100644 index 00000000000..495035592e2 --- /dev/null +++ b/src/decorator/accessors/standard/private/instance/cls-expr.template @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/accessor/private/instance/ +name: private acessor decorator behavior in class expression +features: [class, decorators, class-fields-private] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +var C = class { + /*{ application }*/ + accessor #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +/*{ assertions }*/ diff --git a/src/decorator/accessors/standard/private/static/cls-decl.template b/src/decorator/accessors/standard/private/static/cls-decl.template new file mode 100644 index 00000000000..20c06915aec --- /dev/null +++ b/src/decorator/accessors/standard/private/static/cls-decl.template @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/accessor/private/static/ +name: private static acessor decorator behavior in class declaration +features: [class, decorators, class-static-fields-private] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +class C { + /*{ application }*/ + static accessor #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +/*{ assertions }*/ diff --git a/src/decorator/accessors/standard/private/static/cls-expr.template b/src/decorator/accessors/standard/private/static/cls-expr.template new file mode 100644 index 00000000000..24b6e336f2b --- /dev/null +++ b/src/decorator/accessors/standard/private/static/cls-expr.template @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/accessor/private/static/ +name: private static acessor decorator behavior in class expression +features: [class, decorators, class-static-fields-private] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +var C = class { + /*{ application }*/ + static accessor #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +/*{ assertions }*/ diff --git a/src/decorator/accessors/standard/public/instance/cls-decl.template b/src/decorator/accessors/standard/public/instance/cls-decl.template new file mode 100644 index 00000000000..cb117dd84ce --- /dev/null +++ b/src/decorator/accessors/standard/public/instance/cls-decl.template @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/accessor/public/instance/ +name: public acessor decorator behavior in class declaration +features: [class, decorators, class-fields-public] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +class C { + /*{ application }*/ + accessor element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +/*{ assertions }*/ diff --git a/src/decorator/accessors/standard/public/instance/cls-expr.template b/src/decorator/accessors/standard/public/instance/cls-expr.template new file mode 100644 index 00000000000..28cf8705e81 --- /dev/null +++ b/src/decorator/accessors/standard/public/instance/cls-expr.template @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/accessor/public/instance/ +name: public acessor decorator behavior in class expression +features: [class, decorators, class-fields-public] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +var C = class { + /*{ application }*/ + accessor element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +/*{ assertions }*/ diff --git a/src/decorator/accessors/standard/public/static/cls-decl.template b/src/decorator/accessors/standard/public/static/cls-decl.template new file mode 100644 index 00000000000..66fd17cfa43 --- /dev/null +++ b/src/decorator/accessors/standard/public/static/cls-decl.template @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/accessor/public/static/ +name: public static acessor decorator behavior in class declaration +features: [class, decorators, class-static-fields-public] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +class C { + /*{ application }*/ + static accessor element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +/*{ assertions }*/ diff --git a/src/decorator/accessors/standard/public/static/cls-expr.template b/src/decorator/accessors/standard/public/static/cls-expr.template new file mode 100644 index 00000000000..d176a38fb72 --- /dev/null +++ b/src/decorator/accessors/standard/public/static/cls-expr.template @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/accessor/public/static/ +name: public static acessor decorator behavior in class expression +features: [class, decorators, class-static-fields-public] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +var C = class { + /*{ application }*/ + static accessor element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +/*{ assertions }*/ diff --git a/src/decorator/accessors/with-init/private/instance/cls-decl.template b/src/decorator/accessors/with-init/private/instance/cls-decl.template new file mode 100644 index 00000000000..efac2957726 --- /dev/null +++ b/src/decorator/accessors/with-init/private/instance/cls-decl.template @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/accessor/with-init/private/instance/ +name: private accessor with initializer decorator behavior in class declaration +features: [class, decorators, class-fields-private] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +class C { + /*{ application }*/ + accessor #element = /*{ initializer }*/; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +/*{ assertions }*/ diff --git a/src/decorator/accessors/with-init/private/instance/cls-expr.template b/src/decorator/accessors/with-init/private/instance/cls-expr.template new file mode 100644 index 00000000000..d492e879376 --- /dev/null +++ b/src/decorator/accessors/with-init/private/instance/cls-expr.template @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/accessor/with-init/private/instance/ +name: private accessor with initializer decorator behavior in class expression +features: [class, decorators, class-fields-private] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +var C = class { + /*{ application }*/ + accessor #element = /*{ initializer }*/; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +/*{ assertions }*/ diff --git a/src/decorator/accessors/with-init/private/static/cls-decl.template b/src/decorator/accessors/with-init/private/static/cls-decl.template new file mode 100644 index 00000000000..05012a55fec --- /dev/null +++ b/src/decorator/accessors/with-init/private/static/cls-decl.template @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/accessor/with-init/private/static/ +name: private static with initializer acessor decorator behavior in class declaration +features: [class, decorators, class-static-fields-private] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +class C { + /*{ application }*/ + static accessor #element = /*{ initializer }*/; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +/*{ assertions }*/ diff --git a/src/decorator/accessors/with-init/private/static/cls-expr.template b/src/decorator/accessors/with-init/private/static/cls-expr.template new file mode 100644 index 00000000000..f9b48a13515 --- /dev/null +++ b/src/decorator/accessors/with-init/private/static/cls-expr.template @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/accessor/with-init/private/static/ +name: private static with initializer acessor decorator behavior in class expression +features: [class, decorators, class-static-fields-private] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +var C = class { + /*{ application }*/ + static accessor #element = /*{ initializer }*/; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +/*{ assertions }*/ diff --git a/src/decorator/accessors/with-init/public/instance/cls-decl.template b/src/decorator/accessors/with-init/public/instance/cls-decl.template new file mode 100644 index 00000000000..3f69569068d --- /dev/null +++ b/src/decorator/accessors/with-init/public/instance/cls-decl.template @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/accessor/with-init/public/instance/ +name: public accessor with initializer decorator behavior in class declaration +features: [class, decorators, class-fields-public] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +class C { + /*{ application }*/ + accessor element = /*{ initializer }*/; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +/*{ assertions }*/ diff --git a/src/decorator/accessors/with-init/public/instance/cls-expr.template b/src/decorator/accessors/with-init/public/instance/cls-expr.template new file mode 100644 index 00000000000..31e09837282 --- /dev/null +++ b/src/decorator/accessors/with-init/public/instance/cls-expr.template @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/accessor/with-init/public/instance/ +name: public accessor with initializer decorator behavior in class expression +features: [class, decorators, class-fields-public] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +var C = class { + /*{ application }*/ + accessor element = /*{ initializer }*/; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +/*{ assertions }*/ diff --git a/src/decorator/accessors/with-init/public/static/cls-decl.template b/src/decorator/accessors/with-init/public/static/cls-decl.template new file mode 100644 index 00000000000..7f23ae3fa0e --- /dev/null +++ b/src/decorator/accessors/with-init/public/static/cls-decl.template @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/accessor/with-init/public/static/ +name: public static with initializer acessor decorator behavior in class declaration +features: [class, decorators, class-static-fields-public] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +class C { + /*{ application }*/ + static accessor element = /*{ initializer }*/; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +/*{ assertions }*/ diff --git a/src/decorator/accessors/with-init/public/static/cls-expr.template b/src/decorator/accessors/with-init/public/static/cls-expr.template new file mode 100644 index 00000000000..c0401d54309 --- /dev/null +++ b/src/decorator/accessors/with-init/public/static/cls-expr.template @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/accessor/with-init/public/static/ +name: public static with initializer acessor decorator behavior in class expression +features: [class, decorators, class-static-fields-public] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +var C = class { + /*{ application }*/ + static accessor element = /*{ initializer }*/; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +/*{ assertions }*/ diff --git a/src/decorator/class-deco-invalid-return-arrow.case b/src/decorator/class-deco-invalid-return-arrow.case new file mode 100644 index 00000000000..863e2a5157f --- /dev/null +++ b/src/decorator/class-deco-invalid-return-arrow.case @@ -0,0 +1,20 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-applydecoratorstoclassdefinition +desc: Class decorator cannot return non-newable function (arrow) +template: class/error +features: [decorators] +---*/ + +//- decorators +function dec() { + return () => {} +} + +//- application +@dec + +//- error +TypeError diff --git a/src/decorator/class-deco-invalid-return-primitive.case b/src/decorator/class-deco-invalid-return-primitive.case new file mode 100644 index 00000000000..b90d74ea2e3 --- /dev/null +++ b/src/decorator/class-deco-invalid-return-primitive.case @@ -0,0 +1,20 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-applydecoratorstoclassdefinition +desc: Class decorator cannot return a random non-newable value +template: class/error +features: [decorators] +---*/ + +//- decorators +function dec() { + return 123; +} + +//- application +@dec + +//- error +TypeError diff --git a/src/decorator/class-deco-rebinds-identifier.case b/src/decorator/class-deco-rebinds-identifier.case new file mode 100644 index 00000000000..7ad3400a9f0 --- /dev/null +++ b/src/decorator/class-deco-rebinds-identifier.case @@ -0,0 +1,32 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-applydecoratorstoclassdefinition +desc: Class decorator return value is rebound before static fields are run +template: class/standard/cls-decl.template +features: [decorators] +---*/ + +//- decorators +var originalClass; +var subClass; + +function dec(C, context) { + originalClass = C; + subClass = class D extends C {} + + return subClass; +} + +//- application +@dec + +//- elements +static foo = assert(C === subClass, 'class identifier was rebound'); + +//- assertions +var c = new C(); + +assert.sameValue(C, subClass); +assert(c instanceof originalClass, 'new class is subclass of old class'); diff --git a/src/decorator/class-deco-returns-class.case b/src/decorator/class-deco-returns-class.case new file mode 100644 index 00000000000..870dc82c8b7 --- /dev/null +++ b/src/decorator/class-deco-returns-class.case @@ -0,0 +1,33 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-applydecoratorstoclassdefinition +desc: Class decorator can return a new class +template: class/standard +features: [decorators] +---*/ + +//- decorators +var originalClass; +var newClass; + +function dec(C, context) { + originalClass = C; + newClass = class D { + static foo() { + return 123; + } + }; + + return newClass; +} + +//- application +@dec + +//- assertions +assert.sameValue(C, newClass); +assert(!(C instanceof originalClass), 'new class is not a subclass of old class'); +assert.sameValue(C.foo(), 123); + diff --git a/src/decorator/class-deco-returns-function.case b/src/decorator/class-deco-returns-function.case new file mode 100644 index 00000000000..c0e1f9925b0 --- /dev/null +++ b/src/decorator/class-deco-returns-function.case @@ -0,0 +1,23 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-applydecoratorstoclassdefinition +desc: Class decorator can return a standard function +template: class/standard +features: [decorators] +---*/ + +//- decorators +function dec(C, context) { + return function() { + return 123; + }; +} + +//- application +@dec + +//- assertions +assert.sameValue(C(), 123); + diff --git a/src/decorator/class-deco-returns-proxy.case b/src/decorator/class-deco-returns-proxy.case new file mode 100644 index 00000000000..e3ec78abd95 --- /dev/null +++ b/src/decorator/class-deco-returns-proxy.case @@ -0,0 +1,31 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-applydecoratorstoclassdefinition +desc: Class decorator can return a Proxy +template: class/standard +features: [decorators, Proxy] +---*/ + +//- decorators +var originalClass; +var subClass; + +function dec(C, context) { + originalClass = C; + + return new Proxy(C, { + construct() { + return 123; + } + }); +} + +//- application +@dec + +//- assertions +assert(C !== originalClass, 'values are not the same'); +assert(C instanceof originalClass, 'value is instance of class'); +assert.sameValue(new C(), 123); diff --git a/src/decorator/class-deco-returns-subclass.case b/src/decorator/class-deco-returns-subclass.case new file mode 100644 index 00000000000..af6ac2d5dd0 --- /dev/null +++ b/src/decorator/class-deco-returns-subclass.case @@ -0,0 +1,34 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-applydecoratorstoclassdefinition +desc: Class decorator can return a new class +template: class/standard +features: [decorators] +---*/ + +//- decorators +var originalClass; +var subClass; + +function dec(C, context) { + originalClass = C; + subClass = class D extends C { + static foo() { + return 123; + } + }; + + return subClass; +} + +//- application +@dec + +//- assertions +var c = new C(); + +assert.sameValue(C, subClass); +assert(c instanceof originalClass, 'new class is subclass of old class'); +assert.sameValue(C.foo(), 123); diff --git a/src/decorator/class/error/cls-decl.template b/src/decorator/class/error/cls-decl.template new file mode 100644 index 00000000000..e1db2431c04 --- /dev/null +++ b/src/decorator/class/error/cls-decl.template @@ -0,0 +1,18 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/class/error/ +name: class decorator evaluation error in class declaration +features: [class, decorators] +esid: prod-ClassDeclaration +---*/ + +/*{ decorators }*/ + +function evaluate() { + /*{ application }*/ + class C {} +} + +assert.throws(/*{ error }*/, evaluate); diff --git a/src/decorator/class/error/cls-expr.template b/src/decorator/class/error/cls-expr.template new file mode 100644 index 00000000000..1faaa7daecf --- /dev/null +++ b/src/decorator/class/error/cls-expr.template @@ -0,0 +1,21 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/class/error/ +name: private method decorator evaluation error in class expression +features: [class, decorators, class-methods-private] +esid: prod-ClassExpression +---*/ + +/*{ decorators }*/ + +function evaluate() { + var C = class { + /*{ application }*/ + #element() {} + } +} + +assert.throws(/*{ error }*/, evaluate); + diff --git a/src/decorator/class/standard/cls-decl.template b/src/decorator/class/standard/cls-decl.template new file mode 100644 index 00000000000..9ab5774f734 --- /dev/null +++ b/src/decorator/class/standard/cls-decl.template @@ -0,0 +1,18 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/class/ +name: decorator usage in a class declaration +features: [class] +esid: prod-ClassDeclaration +---*/ + +/*{ decorators }*/ + +/*{ application }*/ +class C { + /*{ elements }*/ +} + +/*{ assertions }*/ diff --git a/src/decorator/class/standard/cls-expr.template b/src/decorator/class/standard/cls-expr.template new file mode 100644 index 00000000000..ff78d62e6cb --- /dev/null +++ b/src/decorator/class/standard/cls-expr.template @@ -0,0 +1,17 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/class/ +name: decorator usage in a class expression +features: [class] +esid: prod-FieldExpression +---*/ + +/*{ decorators }*/ + +var C = /*{ application }*/ class { + /*{ elements }*/ +} + +/*{ assertions }*/ diff --git a/src/decorator/class/with-super-class/cls-decl.template b/src/decorator/class/with-super-class/cls-decl.template new file mode 100644 index 00000000000..e3158b4e439 --- /dev/null +++ b/src/decorator/class/with-super-class/cls-decl.template @@ -0,0 +1,20 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/class/with-super-class/ +name: decorator usage in a class declaration +features: [class] +esid: prod-ClassDeclaration +---*/ + +/*{ decorators }*/ + +class B {} + +/*{ application }*/ +class C extends B { + /*{ elements }*/ +} + +/*{ assertions }*/ diff --git a/src/decorator/class/with-super-class/cls-expr.template b/src/decorator/class/with-super-class/cls-expr.template new file mode 100644 index 00000000000..b437f9fbd2c --- /dev/null +++ b/src/decorator/class/with-super-class/cls-expr.template @@ -0,0 +1,19 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/class/with-super-class/ +name: decorator usage in a class expression +features: [class] +esid: prod-ClassExpression +---*/ + +/*{ decorators }*/ + +class B {} + +var C = /*{ application }*/ class extends B { + /*{ elements }*/ +} + +/*{ assertions }*/ diff --git a/src/decorator/context-access-get.case b/src/decorator/context-access-get.case new file mode 100644 index 00000000000..e3e8027a58d --- /dev/null +++ b/src/decorator/context-access-get.case @@ -0,0 +1,33 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-createdecoratorcontextobject +desc: Context access `get` works on all gettable types of values +templates: + - accessors/standard/**/* + - accessors/with-init/**/* + - fields/standard + - fields/with-init/**/* + - methods/standard/**/* + - methods/async + - methods/generator + - getters/standard +features: [decorators] +---*/ + +//- initializer +123 + +//- decorators +var access; + +function dec(_, context) { + access = context.access; +} + +//- application +@dec + +//- assertions +assert.sameValue(classOrInstance.getElement(), access.get(classOrInstance)); diff --git a/src/decorator/context-access-set.case b/src/decorator/context-access-set.case new file mode 100644 index 00000000000..4aeb92af270 --- /dev/null +++ b/src/decorator/context-access-set.case @@ -0,0 +1,31 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-createdecoratorcontextobject +desc: Context access `get` works on all gettable types of values +templates: + - accessors/standard/**/* + - accessors/with-init/**/* + - fields/standard/**/* + - fields/with-init/**/* + - setters/standard/**/* +features: [decorators] +---*/ + +//- decorators +var access; + +function dec(_, context) { + access = context.access; +} + +//- initializer +123 + +//- application +@dec + +//- assertions +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/src/decorator/context-kind-accessor.case b/src/decorator/context-kind-accessor.case new file mode 100644 index 00000000000..6ab0317f86f --- /dev/null +++ b/src/decorator/context-kind-accessor.case @@ -0,0 +1,17 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-createdecoratorcontextobject +desc: Context kind is the string "accessor" when decorating a method +template: accessors/standard/**/* +features: [decorators] +---*/ + +//- decorators +function dec(_, context) { + assert.sameValue(context.kind, "accessor"); +} + +//- application +@dec diff --git a/src/decorator/context-kind-class.case b/src/decorator/context-kind-class.case new file mode 100644 index 00000000000..6961bd0213e --- /dev/null +++ b/src/decorator/context-kind-class.case @@ -0,0 +1,17 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-createdecoratorcontextobject +desc: Context kind is the string "class" when decorating a method +template: class/standard +features: [decorators] +---*/ + +//- decorators +function dec(_, context) { + assert.sameValue(context.kind, "class"); +} + +//- application +@dec diff --git a/src/decorator/context-kind-field.case b/src/decorator/context-kind-field.case new file mode 100644 index 00000000000..08f92e108c7 --- /dev/null +++ b/src/decorator/context-kind-field.case @@ -0,0 +1,17 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-createdecoratorcontextobject +desc: Context kind is the string "field" when decorating a field +template: fields/standard/**/* +features: [decorators] +---*/ + +//- decorators +function dec(_, context) { + assert.sameValue(context.kind, "field"); +} + +//- application +@dec diff --git a/src/decorator/context-kind-getter.case b/src/decorator/context-kind-getter.case new file mode 100644 index 00000000000..98ae7c6183e --- /dev/null +++ b/src/decorator/context-kind-getter.case @@ -0,0 +1,17 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-createdecoratorcontextobject +desc: Context kind is the string "method" when decorating a method +template: getters/standard/**/* +features: [decorators] +---*/ + +//- decorators +function dec(_, context) { + assert.sameValue(context.kind, "getter"); +} + +//- application +@dec diff --git a/src/decorator/context-kind-method.case b/src/decorator/context-kind-method.case new file mode 100644 index 00000000000..78129a05ae8 --- /dev/null +++ b/src/decorator/context-kind-method.case @@ -0,0 +1,20 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-createdecoratorcontextobject +desc: Context kind is the string "method" when decorating a method +templates: + - methods/standard/**/* + - methods/async/**/* + - methods/generator/**/* +features: [decorators] +---*/ + +//- decorators +function dec(_, context) { + assert.sameValue(context.kind, "method"); +} + +//- application +@dec diff --git a/src/decorator/context-kind-setter.case b/src/decorator/context-kind-setter.case new file mode 100644 index 00000000000..7f79aedcbee --- /dev/null +++ b/src/decorator/context-kind-setter.case @@ -0,0 +1,17 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-createdecoratorcontextobject +desc: Context kind is the string "setter" when decorating a method +template: setters/standard/**/* +features: [decorators] +---*/ + +//- decorators +function dec(_, context) { + assert.sameValue(context.kind, "setter"); +} + +//- application +@dec diff --git a/src/decorator/context-name-class.case b/src/decorator/context-name-class.case new file mode 100644 index 00000000000..5495467b46b --- /dev/null +++ b/src/decorator/context-name-class.case @@ -0,0 +1,17 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-createdecoratorcontextobject +desc: Name of the class is correct on the context object +template: class/standard +features: [decorators] +---*/ + +//- decorators +function dec(_, context) { + assert.sameValue(context.name, "C"); +} + +//- application +@dec diff --git a/src/decorator/context-name-private.case b/src/decorator/context-name-private.case new file mode 100644 index 00000000000..32aaac21b30 --- /dev/null +++ b/src/decorator/context-name-private.case @@ -0,0 +1,22 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-createdecoratorcontextobject +desc: Context name is correct for all types of private elements +templates: + - accessors/standard/private/**/* + - fields/standard/private/**/* + - getters/standard/private/**/* + - methods/standard/private/**/* + - setters/standard/private/**/* +features: [decorators] +---*/ + +//- decorators +function dec(_, context) { + assert.sameValue(context.name, "#element"); +} + +//- application +@dec diff --git a/src/decorator/context-name-public.case b/src/decorator/context-name-public.case new file mode 100644 index 00000000000..a08448d8c09 --- /dev/null +++ b/src/decorator/context-name-public.case @@ -0,0 +1,22 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-createdecoratorcontextobject +desc: Context name is correct for all types of public elements +templates: + - accessors/standard/public/**/* + - fields/standard/public/**/* + - getters/standard/public/**/* + - methods/standard/public/**/* + - setters/standard/public/**/* +features: [decorators] +---*/ + +//- decorators +function dec(_, context) { + assert.sameValue(context.name, "element"); +} + +//- application +@dec diff --git a/src/decorator/context-private-false.case b/src/decorator/context-private-false.case new file mode 100644 index 00000000000..507acd86465 --- /dev/null +++ b/src/decorator/context-private-false.case @@ -0,0 +1,22 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-createdecoratorcontextobject +desc: Context `private` is true for all types of private elements +templates: + - accessors/standard/private/**/* + - fields/standard/private/**/* + - getters/standard/private/**/* + - methods/standard/private/**/* + - setters/standard/private/**/* +features: [decorators] +---*/ + +//- decorators +function dec(_, context) { + assert.sameValue(context.private, true); +} + +//- application +@dec diff --git a/src/decorator/context-private-true.case b/src/decorator/context-private-true.case new file mode 100644 index 00000000000..bdd5bf2ac10 --- /dev/null +++ b/src/decorator/context-private-true.case @@ -0,0 +1,22 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-createdecoratorcontextobject +desc: Context `private` is false for all types of public elements +templates: + - accessors/standard/public/**/* + - fields/standard/public/**/* + - getters/standard/public/**/* + - methods/standard/public/**/* + - setters/standard/public/**/* +features: [decorators] +---*/ + +//- decorators +function dec(_, context) { + assert.sameValue(context.private, false); +} + +//- application +@dec diff --git a/src/decorator/context-static-false.case b/src/decorator/context-static-false.case new file mode 100644 index 00000000000..7d7281b983b --- /dev/null +++ b/src/decorator/context-static-false.case @@ -0,0 +1,27 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-createdecoratorcontextobject +desc: Context `static` is false for all types of instance elements +templates: + - accessors/standard/private/instance + - accessors/standard/public/instance + - fields/standard/private/instance + - fields/standard/public/instance + - getters/standard/private/instance + - getters/standard/public/instance + - methods/standard/private/instance + - methods/standard/public/instance + - setters/standard/private/instance + - setters/standard/public/instance +features: [decorators] +---*/ + +//- decorators +function dec(_, context) { + assert.sameValue(context.static, false); +} + +//- application +@dec diff --git a/src/decorator/context-static-true.case b/src/decorator/context-static-true.case new file mode 100644 index 00000000000..ad277f75403 --- /dev/null +++ b/src/decorator/context-static-true.case @@ -0,0 +1,27 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-createdecoratorcontextobject +desc: Context `static` is false for all types of instance elements +templates: + - accessors/standard/private/static + - accessors/standard/public/static + - fields/standard/private/static + - fields/standard/public/static + - getters/standard/private/static + - getters/standard/public/static + - methods/standard/private/static + - methods/standard/public/static + - setters/standard/private/static + - setters/standard/public/static +features: [decorators] +---*/ + +//- decorators +function dec(_, context) { + assert.sameValue(context.static, true); +} + +//- application +@dec diff --git a/src/decorator/decorator-order-application-field-and-accessor.case b/src/decorator/decorator-order-application-field-and-accessor.case new file mode 100644 index 00000000000..89973932846 --- /dev/null +++ b/src/decorator/decorator-order-application-field-and-accessor.case @@ -0,0 +1,42 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-function-objects-construct-argumentslist-newtarget +desc: Order of decorator application for elements with initializers +templates: + - accessors/with-init/**/* + - fields/with-init/**/* +features: [decorators] +---*/ + +//- decorators +var ord = []; + +function pushOrd(applyOrd, initOrd, extraInitOrd) { + return (value, context) => { + ord.push(applyOrd); + context.addInitializer(() => ord.push(extraInitOrd)); + + if (context.kind === 'field') { + return () => ord.push(initOrd); + } else { + return { + init() { + ord.push(initOrd); + } + } + } + } +} + +//- initializer +ord.push(2) + +//- application +@pushOrd(1, 3, 6) +@pushOrd(0, 4, 5) + +//- assertions +assert.sameValue(ord.length, 7); +ord.forEach(assert.sameValue); diff --git a/src/decorator/decorator-order-application-method-and-class.case b/src/decorator/decorator-order-application-method-and-class.case new file mode 100644 index 00000000000..e4240de9e12 --- /dev/null +++ b/src/decorator/decorator-order-application-method-and-class.case @@ -0,0 +1,31 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-runtime-semantics-classdefinitionevaluation +desc: Order of decorator application for elements without initializers +templates: + - class/standard + - getters/standard + - methods/standard/**/* + - setters/standard +features: [decorators] +---*/ + +//- decorators +var ord = []; + +function pushOrd(applyOrd, extraInitOrd) { + return (value, context) => { + ord.push(applyOrd); + context.addInitializer(() => ord.push(extraInitOrd)); + } +} + +//- application +@pushOrd(1, 3) +@pushOrd(0, 2) + +//- assertions +assert.sameValue(ord.length, 4); +ord.forEach(assert.sameValue); diff --git a/src/decorator/decorator-order-phases-1-pre-definition.case b/src/decorator/decorator-order-phases-1-pre-definition.case new file mode 100644 index 00000000000..56f0c7b9e91 --- /dev/null +++ b/src/decorator/decorator-order-phases-1-pre-definition.case @@ -0,0 +1,72 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-runtime-semantics-classdefinitionevaluation +desc: Class pre-definition evaluation phase order +info: | + In the pre-definition phase, all expressions that are part of the class + definition itself are evaluated to get the final concrete values that are + needed to fully evaluate the class itself. This includes: + + - Dynamic element names + - Decorator expressions (e.g. `@foo()`, which calls a function and returns a + decorator) + + These are evaluated in lexical order from top to bottom. + +template: class/standard +features: [decorators] +---*/ + +//- decorators +var ord = []; + +// For dynamic element name evaluation order +function dynamicName(name, order) { + ord.push(order); + return name; +} + +function pushOrd(evalOrd) { + ord.push(evalOrd); + + return () => { + // do nothing + } +} + +ord.push(0); + +//- application +@pushOrd(1) + +//- elements + +@pushOrd(2) +[dynamicName('a', 3)]() {} + +@pushOrd(4) +#b() {} + +@pushOrd(5) +static [dynamicName('c', 6)]() {} + +@pushOrd(7) +static #d() {} + +@pushOrd(8) +[dynamicName('e', 9)] = 123; + +@pushOrd(10) +#f = 123; + +//- assertions +ord.push(11); + +new C(); + +ord.push(12); + +assert.sameValue(ord.length, 13); +ord.forEach(assert.sameValue); diff --git a/src/decorator/decorator-order-phases-2-application.case b/src/decorator/decorator-order-phases-2-application.case new file mode 100644 index 00000000000..bc1d2a80cb5 --- /dev/null +++ b/src/decorator/decorator-order-phases-2-application.case @@ -0,0 +1,78 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-runtime-semantics-classdefinitionevaluation +desc: Class definition decorator application order +info: | + In the application phase, decorators are applied to each element in the + following order: + + 1. Static methods + 2. Instance methods + 3. Static fields + 4. Instance fields + 5. Class + + Within each group, decorators are applied to each _element_ in lexical order, + from top to bottom (note: This refers to ordering _between_ elements. Within a + single element definition, decorators are applied in reverse lexical order.) + As each method is defined, the method itself is assigned to the prototype or + class definition. + +template: class/standard +features: [decorators] +---*/ + +//- decorators +var ord = []; + +function pushOrd(applyOrd) { + return () => { + ord.push(applyOrd); + } +} + +ord.push(0); + + +//- application +@pushOrd(9) + + +//- elements +@pushOrd(8) +a = 123; + +@pushOrd(4) +b() {} + +@pushOrd(1) +static accessor c = 123; + +@pushOrd(2) +static get d() {} + + +@pushOrd(5) +accessor e = 123; + +@pushOrd(6) +get f() {} + +@pushOrd(7) +static g = 123; + +@pushOrd(3) +static h() {} + + +//- assertions +ord.push(10); + +new C(); + +ord.push(11); + +assert.sameValue(ord.length, 12); +ord.forEach(assert.sameValue); diff --git a/src/decorator/decorator-order-phases-3-init-static.case b/src/decorator/decorator-order-phases-3-init-static.case new file mode 100644 index 00000000000..087770a7302 --- /dev/null +++ b/src/decorator/decorator-order-phases-3-init-static.case @@ -0,0 +1,101 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-runtime-semantics-classdefinitionevaluation +desc: Class definition static initialization order +info: | + In the static initialization phase, the class definition is initialized in the + following order: + + 1. Static method extra-initializers are run, finalizing static method + definition. + 2. Static fields and blocks are evaluated and assigned in lexical order. For + each field, extra-initializers are run for that field immediately after + assignment. + 3. Class extra-initializers are run, finalizing the class definition. + + After this, the class is fully defined. + +template: class/standard +features: [decorators] +---*/ + +//- decorators +var ord = []; + +// For dynamic element name evaluation order +function dynamicName(name, order) { + ord.push(order); + return name; +} + +function pushOrd(initOrd, extraInitOrd) { + return (value, context) => { + if (context.kind === 'field') { + context.addInitializer(() => ord.push(extraInitOrd)); + + return () => ord.push(initOrd); + } else if (context.kind === 'accessor') { + context.addInitializer(() => ord.push(extraInitOrd)); + + return { + init() { + ord.push(initOrd); + } + } + } else { + context.addInitializer(() => ord.push(initOrd)); + } + } +} + +ord.push(0); + + +//- application +@pushOrd(12) + + +//- elements +static { + ord.push(3); +} + + +@pushOrd(1) +static a() {} + +@pushOrd(5, 6) +static accessor b = ord.push(4); + +e = ord.push(14); + + +static { + ord.push(7); +} + + +accessor e = ord.push(15); + +@pushOrd(2) +static get c() {} + +@pushOrd(9, 10) +static d = ord.push(8); + + +static { + ord.push(11); +} + +//- assertions +ord.push(13); + +new C(); + +ord.push(16); + +assert.sameValue(ord.length, 17); +ord.forEach(assert.sameValue); diff --git a/src/decorator/decorator-order-phases-4-init-instance.case b/src/decorator/decorator-order-phases-4-init-instance.case new file mode 100644 index 00000000000..f3fef58ba29 --- /dev/null +++ b/src/decorator/decorator-order-phases-4-init-instance.case @@ -0,0 +1,84 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-function-objects-construct-argumentslist-newtarget +desc: Class instance creation order +info: | + Class instances are created in the following order: + + 1. The class constructor begins evaluating + 2. Super class is fully initialized (e.g. `super()` is called) + 3. Prototype method extra initializers are run, finalizing method definitions + 4. Instance field/accessors are assigned, and field/accessor extra + initializers run immediately after each field/accessor assignment. + +template: class/with-super-class +features: [decorators] +---*/ + +//- decorators +var ord = []; + +// For dynamic element name evaluation order +function dynamicName(name, order) { + ord.push(order); + return name; +} + +function pushOrd(initOrd, extraInitOrd) { + return (value, context) => { + if (context.kind === 'field') { + context.addInitializer(() => ord.push(extraInitOrd)); + + return () => ord.push(initOrd); + } else if (context.kind === 'accessor') { + context.addInitializer(() => ord.push(extraInitOrd)); + + return { + init() { + ord.push(initOrd); + } + } + } else { + context.addInitializer(() => ord.push(initOrd)); + } + } +} + +ord.push(0); + + +//- elements +constructor() { + ord.push(2); + super(); + ord.push(13); +} + +a = ord.push(5); + +@pushOrd(3) +b() {} + +@pushOrd(7, 8) +accessor c = ord.push(6); + +@pushOrd(4) +get d() {} + +accessor f = ord.push(9); + +@pushOrd(11, 12) +e = ord.push(10); + + +//- assertions +ord.push(1); + +new C(); + +ord.push(14); + +assert.sameValue(ord.length, 15); +ord.forEach(assert.sameValue); diff --git a/src/decorator/decorator-order-phases.case b/src/decorator/decorator-order-phases.case new file mode 100644 index 00000000000..32e48133f6c --- /dev/null +++ b/src/decorator/decorator-order-phases.case @@ -0,0 +1,74 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-runtime-semantics-classdefinitionevaluation +desc: Order of decorators +info: | + With decorators, definition and instantiation happens in 3 main observable + phases: + + 1. Pre-definition: + + Class key expressions and decorator expressions are evaluated, giving us + all the concrete values that are needed to fully evaluate the class + definition. + + 2. Decorator application and method assignment: + + Decorators are applied to each class element, and methods are + assigned to the class prototype (or class for static methods). Class + decorators are run after all other decorators, and the class identifier + is rebound to the final return value. + + 3. Static initialization: + + Static method extra initializers are run, then static blocks and fields + are initialized and assigned and field extra initializers are run. + Finally, class extra initializers are run. The class is now fully + defined. + + 4. Class instantiation: + + The last phases instantiation, when an instance is created. Instance + method and field extra initializers are run. + + This test compares the relative ordering of these phases, and other tests + check the ordering within each phase + +template: class/standard +features: [decorators] +---*/ + +//- decorators +var ord = []; + +function pushOrd(evalOrd, applyOrd, initOrd) { + ord.push(evalOrd); + + return (value, context) => { + ord.push(applyOrd); + + context.addInitializer(() => ord.push(initOrd)); + } +} + +ord.push(0); + +//- application +@pushOrd(1, 6, 7) + +//- elements +@pushOrd(2, 4, 9) +a() {} + +@pushOrd(3, 5, 10) +b() {} + +//- assertions +ord.push(8); + +new C(); + +assert.sameValue(ord.length, 11); +ord.forEach(assert.sameValue); diff --git a/src/decorator/field-and-accessor-init-this.case b/src/decorator/field-and-accessor-init-this.case new file mode 100644 index 00000000000..e4ee2d7d967 --- /dev/null +++ b/src/decorator/field-and-accessor-init-this.case @@ -0,0 +1,33 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-initializefieldoraccessor +desc: Field initializer `this` value is the instance or the class +templates: + - fields/standard/**/* + - fields/with-init/**/* + - accessors/standard/**/* + - accessors/with-init/**/* +features: [decorators] +---*/ + +//- decorators +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + +//- application +@dec + +//- initializer +savedThisValues.push(this); + +//- assertions +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/src/decorator/field-deco-invalid-return.case b/src/decorator/field-deco-invalid-return.case new file mode 100644 index 00000000000..d9767f603f1 --- /dev/null +++ b/src/decorator/field-deco-invalid-return.case @@ -0,0 +1,20 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-applydecoratorstoelementdefinition +desc: Decorator can't return an invalid value +template: fields/error/**/* +features: [decorators] +---*/ + +//- decorators +function dec(value) { + return 123; +} + +//- application +@dec + +//- error +TypeError diff --git a/src/decorator/field-deco-returns-initializer.case b/src/decorator/field-deco-returns-initializer.case new file mode 100644 index 00000000000..4469dcc9f77 --- /dev/null +++ b/src/decorator/field-deco-returns-initializer.case @@ -0,0 +1,23 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-initializefieldoraccessor +desc: Decorator and initializer order +template: fields/standard/**/* +features: [decorators] +---*/ + +//- decorators +function dec(value) { + return (init) => { + assert.sameValue(init, undefined); + return 123; + } +} + +//- application +@dec + +//- assertions +assert.sameValue(classOrInstance.getElement(), 123); diff --git a/src/decorator/field-deco-returns-undefined.case b/src/decorator/field-deco-returns-undefined.case new file mode 100644 index 00000000000..e51a2171dc0 --- /dev/null +++ b/src/decorator/field-deco-returns-undefined.case @@ -0,0 +1,20 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-initializefieldoraccessor +desc: Decorator can return undefined +template: fields/standard/**/* +features: [decorators] +---*/ + +//- decorators +function dec(value) { + assert.sameValue(value, undefined); +} + +//- application +@dec + +//- assertions +assert.sameValue(classOrInstance.getElement(), undefined); diff --git a/src/decorator/field-receives-undefined.case b/src/decorator/field-receives-undefined.case new file mode 100644 index 00000000000..d7ee664e4f0 --- /dev/null +++ b/src/decorator/field-receives-undefined.case @@ -0,0 +1,22 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-applydecoratorstoelementdefinition +desc: Value passed to field decorators is undefined +templates: + - fields/standard + - fields/with-init/**/* +features: [decorators] +---*/ + +//- decorators +function dec(value) { + assert.sameValue(value, undefined); +} + +//- initializer +123 + +//- application +@dec diff --git a/src/decorator/field-with-init-deco-returns-initializer.case b/src/decorator/field-with-init-deco-returns-initializer.case new file mode 100644 index 00000000000..6d81182e0a6 --- /dev/null +++ b/src/decorator/field-with-init-deco-returns-initializer.case @@ -0,0 +1,31 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-initializefieldoraccessor +desc: Decorator initializer is called with initial value during initialization +info: | + InitializeFieldOrAccessor ( receiver, elementRecord ) + + ... + +template: fields/with-init/**/* +features: [decorators] +---*/ + +//- initializer +123 + +//- decorators +function dec(value) { + return (init) => { + assert.sameValue(init, 123); + return 456; + } +} + +//- application +@dec + +//- assertions +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/src/decorator/field-with-init-deco-returns-undefined.case b/src/decorator/field-with-init-deco-returns-undefined.case new file mode 100644 index 00000000000..a2169bb191a --- /dev/null +++ b/src/decorator/field-with-init-deco-returns-undefined.case @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-initializefieldoraccessor +desc: Decorator initializer is called with initial value during initialization +info: | + InitializeFieldOrAccessor ( receiver, elementRecord ) + + ... + +template: fields/with-init/**/* +features: [decorators] +---*/ + +//- initializer +123 + +//- decorators +function dec(value) { + assert.sameValue(value, undefined); +} + +//- application +@dec + +//- assertions +assert.sameValue(classOrInstance.getElement(), 123); diff --git a/src/decorator/fields/error/private/instance/cls-decl.template b/src/decorator/fields/error/private/instance/cls-decl.template new file mode 100644 index 00000000000..0e165ab98a5 --- /dev/null +++ b/src/decorator/fields/error/private/instance/cls-decl.template @@ -0,0 +1,20 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/field/error/private/instance/ +name: private field decorator evaluation error in class declaration +features: [class, decorators, class-fields-private] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +function evaluate() { + class C { + /*{ application }*/ + #element; + } +} + +assert.throws(/*{ error }*/, evaluate); diff --git a/src/decorator/fields/error/private/instance/cls-expr.template b/src/decorator/fields/error/private/instance/cls-expr.template new file mode 100644 index 00000000000..6b6a2e3fb0a --- /dev/null +++ b/src/decorator/fields/error/private/instance/cls-expr.template @@ -0,0 +1,21 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/field/error/private/instance/ +name: private field decorator behavior in class expression +features: [class, decorators, class-fields-private] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +function evaluate() { + var C = class { + /*{ application }*/ + #element; + } +} + +assert.throws(/*{ error }*/, evaluate); + diff --git a/src/decorator/fields/error/private/static/cls-decl.template b/src/decorator/fields/error/private/static/cls-decl.template new file mode 100644 index 00000000000..fb7f502ca86 --- /dev/null +++ b/src/decorator/fields/error/private/static/cls-decl.template @@ -0,0 +1,21 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/field/error/private/static/ +name: private static field decorator behavior in class declaration +features: [class, decorators, class-static-fields-private] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +function evaluate() { + class C { + /*{ application }*/ + static #element; + } +} + +assert.throws(/*{ error }*/, evaluate); + diff --git a/src/decorator/fields/error/private/static/cls-expr.template b/src/decorator/fields/error/private/static/cls-expr.template new file mode 100644 index 00000000000..230321051d8 --- /dev/null +++ b/src/decorator/fields/error/private/static/cls-expr.template @@ -0,0 +1,20 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/field/error/private/static/ +name: private static field decorator behavior in class expression +features: [class, decorators, class-static-fields-private] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +function evaluate() { + var C = class { + /*{ application }*/ + static #element; + } +} + +assert.throws(/*{ error }*/, evaluate); diff --git a/src/decorator/fields/error/public/instance/cls-decl.template b/src/decorator/fields/error/public/instance/cls-decl.template new file mode 100644 index 00000000000..4cc5818ca67 --- /dev/null +++ b/src/decorator/fields/error/public/instance/cls-decl.template @@ -0,0 +1,21 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/field/error/public/instance/ +name: public field decorator behavior in class declaration +features: [class, decorators, class-fields-public] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +function evaluate() { + class C { + /*{ application }*/ + element; + } +} + +assert.throws(/*{ error }*/, evaluate); + diff --git a/src/decorator/fields/error/public/instance/cls-expr.template b/src/decorator/fields/error/public/instance/cls-expr.template new file mode 100644 index 00000000000..bf7c413489d --- /dev/null +++ b/src/decorator/fields/error/public/instance/cls-expr.template @@ -0,0 +1,21 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/field/error/public/instance/ +name: public field decorator behavior in class expression +features: [class, decorators, class-fields-public] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +function evaluate() { + var C = class { + /*{ application }*/ + element; + } +} + +assert.throws(/*{ error }*/, evaluate); + diff --git a/src/decorator/fields/error/public/static/cls-decl.template b/src/decorator/fields/error/public/static/cls-decl.template new file mode 100644 index 00000000000..715b6e1533a --- /dev/null +++ b/src/decorator/fields/error/public/static/cls-decl.template @@ -0,0 +1,21 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/field/public/static/ +name: public static field decorator behavior in class declaration +features: [class, decorators, class-static-fields-public] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +function evaluate() { + class C { + /*{ application }*/ + static element; + } +} + +assert.throws(/*{ error }*/, evaluate); + diff --git a/src/decorator/fields/error/public/static/cls-expr.template b/src/decorator/fields/error/public/static/cls-expr.template new file mode 100644 index 00000000000..34e8ad0e1f0 --- /dev/null +++ b/src/decorator/fields/error/public/static/cls-expr.template @@ -0,0 +1,20 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/field/public/static/ +name: public static field decorator behavior in class expression +features: [class, decorators, class-static-fields-public] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +function evaluate() { + var C = class { + /*{ application }*/ + static element; + } +} + +assert.throws(/*{ error }*/, evaluate); diff --git a/src/decorator/fields/standard/private/instance/cls-decl.template b/src/decorator/fields/standard/private/instance/cls-decl.template new file mode 100644 index 00000000000..ad75eb8cbf5 --- /dev/null +++ b/src/decorator/fields/standard/private/instance/cls-decl.template @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/field/private/instance/ +name: private field decorator behavior in class declaration +features: [class, decorators, class-fields-private] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +class C { + /*{ application }*/ + #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +/*{ assertions }*/ diff --git a/src/decorator/fields/standard/private/instance/cls-expr.template b/src/decorator/fields/standard/private/instance/cls-expr.template new file mode 100644 index 00000000000..bfe4910ef88 --- /dev/null +++ b/src/decorator/fields/standard/private/instance/cls-expr.template @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/field/private/instance/ +name: private field decorator behavior in class expression +features: [class, decorators, class-fields-private] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +var C = class { + /*{ application }*/ + #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +/*{ assertions }*/ diff --git a/src/decorator/fields/standard/private/static/cls-decl.template b/src/decorator/fields/standard/private/static/cls-decl.template new file mode 100644 index 00000000000..c3ca06e44ea --- /dev/null +++ b/src/decorator/fields/standard/private/static/cls-decl.template @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/field/private/static/ +name: private static field decorator behavior in class declaration +features: [class, decorators, class-static-fields-private] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +class C { + /*{ application }*/ + static #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +/*{ assertions }*/ diff --git a/src/decorator/fields/standard/private/static/cls-expr.template b/src/decorator/fields/standard/private/static/cls-expr.template new file mode 100644 index 00000000000..2d85565016f --- /dev/null +++ b/src/decorator/fields/standard/private/static/cls-expr.template @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/field/private/static/ +name: private static field decorator behavior in class expression +features: [class, decorators, class-static-fields-private] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +var C = class { + /*{ application }*/ + static #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +/*{ assertions }*/ diff --git a/src/decorator/fields/standard/public/instance/cls-decl.template b/src/decorator/fields/standard/public/instance/cls-decl.template new file mode 100644 index 00000000000..936629223d9 --- /dev/null +++ b/src/decorator/fields/standard/public/instance/cls-decl.template @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/field/public/instance/ +name: public field decorator behavior in class declaration +features: [class, decorators, class-fields-public] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +class C { + /*{ application }*/ + element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +/*{ assertions }*/ diff --git a/src/decorator/fields/standard/public/instance/cls-expr.template b/src/decorator/fields/standard/public/instance/cls-expr.template new file mode 100644 index 00000000000..40a88df16f2 --- /dev/null +++ b/src/decorator/fields/standard/public/instance/cls-expr.template @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/field/public/instance/ +name: public field decorator behavior in class expression +features: [class, decorators, class-fields-public] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +var C = class { + /*{ application }*/ + element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +/*{ assertions }*/ diff --git a/src/decorator/fields/standard/public/static/cls-decl.template b/src/decorator/fields/standard/public/static/cls-decl.template new file mode 100644 index 00000000000..c3656f40539 --- /dev/null +++ b/src/decorator/fields/standard/public/static/cls-decl.template @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/field/public/static/ +name: public static field decorator behavior in class declaration +features: [class, decorators, class-static-fields-public] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +class C { + /*{ application }*/ + static element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +/*{ assertions }*/ diff --git a/src/decorator/fields/standard/public/static/cls-expr.template b/src/decorator/fields/standard/public/static/cls-expr.template new file mode 100644 index 00000000000..841e58a9bf7 --- /dev/null +++ b/src/decorator/fields/standard/public/static/cls-expr.template @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/field/public/static/ +name: public static field decorator behavior in class expression +features: [class, decorators, class-static-fields-public] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +var C = class { + /*{ application }*/ + static element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +/*{ assertions }*/ diff --git a/src/decorator/fields/with-init/private/instance/cls-decl.template b/src/decorator/fields/with-init/private/instance/cls-decl.template new file mode 100644 index 00000000000..6fbd2120e1e --- /dev/null +++ b/src/decorator/fields/with-init/private/instance/cls-decl.template @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/field/with-init/private/instance/ +name: private field with initializer decorator behavior in class declaration +features: [class, decorators, class-fields-private] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +class C { + /*{ application }*/ + #element = /*{ initializer }*/; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +/*{ assertions }*/ diff --git a/src/decorator/fields/with-init/private/instance/cls-expr.template b/src/decorator/fields/with-init/private/instance/cls-expr.template new file mode 100644 index 00000000000..5a9faedd2be --- /dev/null +++ b/src/decorator/fields/with-init/private/instance/cls-expr.template @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/field/with-init/private/instance/ +name: private field with initializer decorator behavior in class expression +features: [class, decorators, class-fields-private] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +var C = class { + /*{ application }*/ + #element = /*{ initializer }*/; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +/*{ assertions }*/ diff --git a/src/decorator/fields/with-init/private/static/cls-decl.template b/src/decorator/fields/with-init/private/static/cls-decl.template new file mode 100644 index 00000000000..e28c3f66fc2 --- /dev/null +++ b/src/decorator/fields/with-init/private/static/cls-decl.template @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/field/with-init/private/static/ +name: private static with initializer field decorator behavior in class declaration +features: [class, decorators, class-static-fields-private] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +class C { + /*{ application }*/ + static #element = /*{ initializer }*/; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +/*{ assertions }*/ diff --git a/src/decorator/fields/with-init/private/static/cls-expr.template b/src/decorator/fields/with-init/private/static/cls-expr.template new file mode 100644 index 00000000000..124dddbb9ab --- /dev/null +++ b/src/decorator/fields/with-init/private/static/cls-expr.template @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/field/with-init/private/static/ +name: private static with initializer field decorator behavior in class expression +features: [class, decorators, class-static-fields-private] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +var C = class { + /*{ application }*/ + static #element = /*{ initializer }*/; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +/*{ assertions }*/ diff --git a/src/decorator/fields/with-init/public/instance/cls-decl.template b/src/decorator/fields/with-init/public/instance/cls-decl.template new file mode 100644 index 00000000000..5c38957e36a --- /dev/null +++ b/src/decorator/fields/with-init/public/instance/cls-decl.template @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/field/with-init/public/instance/ +name: public field with initializer decorator behavior in class declaration +features: [class, decorators, class-fields-public] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +class C { + /*{ application }*/ + element = /*{ initializer }*/; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +/*{ assertions }*/ diff --git a/src/decorator/fields/with-init/public/instance/cls-expr.template b/src/decorator/fields/with-init/public/instance/cls-expr.template new file mode 100644 index 00000000000..d9beb0e708a --- /dev/null +++ b/src/decorator/fields/with-init/public/instance/cls-expr.template @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/field/with-init/public/instance/ +name: public field with initializer decorator behavior in class expression +features: [class, decorators, class-fields-public] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +var C = class { + /*{ application }*/ + element = /*{ initializer }*/; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +/*{ assertions }*/ diff --git a/src/decorator/fields/with-init/public/static/cls-decl.template b/src/decorator/fields/with-init/public/static/cls-decl.template new file mode 100644 index 00000000000..c7e369fe191 --- /dev/null +++ b/src/decorator/fields/with-init/public/static/cls-decl.template @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/field/with-init/public/static/ +name: public static with initializer field decorator behavior in class declaration +features: [class, decorators, class-static-fields-public] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +class C { + /*{ application }*/ + static element = /*{ initializer }*/; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +/*{ assertions }*/ diff --git a/src/decorator/fields/with-init/public/static/cls-expr.template b/src/decorator/fields/with-init/public/static/cls-expr.template new file mode 100644 index 00000000000..4c73597fead --- /dev/null +++ b/src/decorator/fields/with-init/public/static/cls-expr.template @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/field/with-init/public/static/ +name: public static with initializer field decorator behavior in class expression +features: [class, decorators, class-static-fields-public] +esid: prod-FieldDefinition +---*/ + +/*{ decorators }*/ + +var C = class { + /*{ application }*/ + static element = /*{ initializer }*/; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +/*{ assertions }*/ diff --git a/src/decorator/getter-deco-returns-invalid.case b/src/decorator/getter-deco-returns-invalid.case new file mode 100644 index 00000000000..76be0bf5bd2 --- /dev/null +++ b/src/decorator/getter-deco-returns-invalid.case @@ -0,0 +1,20 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-applydecoratorstoelementdefinition +desc: Decorator can't return an invalid value +template: getters/error/**/* +features: [decorators] +---*/ + +//- decorators +function dec(_, context) { + return 123; +} + +//- application +@dec + +//- error +TypeError diff --git a/src/decorator/getter-deco-returns-replacement.case b/src/decorator/getter-deco-returns-replacement.case new file mode 100644 index 00000000000..17633d78967 --- /dev/null +++ b/src/decorator/getter-deco-returns-replacement.case @@ -0,0 +1,25 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-applydecoratorstoelementdefinition +desc: Can replace a decorated getter with a new getter +template: getters/standard/**/* +features: [decorators] +---*/ + +//- decorators +function dec(value, context) { + + return function() { + assert.sameValue(value.call(this), 123); + + return 456; + }; +} + +//- application +@dec + +//- assertions +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/src/decorator/getter-deco-returns-undefined.case b/src/decorator/getter-deco-returns-undefined.case new file mode 100644 index 00000000000..b0b5ea91b77 --- /dev/null +++ b/src/decorator/getter-deco-returns-undefined.case @@ -0,0 +1,26 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-applydecoratorstoelementdefinition +desc: Decorator undefined return defaults to previous value +template: getters/standard/**/* +features: [decorators] +---*/ + +//- decorators +function dec1(value, context) { + return function() { + assert.sameValue(value.call(this), 123); + + return 456; + }; +} + +function dec2() {} + +//- application +@dec2 @dec1 + +//- assertions +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/src/decorator/getters/error/private/instance/cls-decl.template b/src/decorator/getters/error/private/instance/cls-decl.template new file mode 100644 index 00000000000..3cab2bf64ee --- /dev/null +++ b/src/decorator/getters/error/private/instance/cls-decl.template @@ -0,0 +1,20 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/getter/error/private/instance/ +name: private getter decorator evaluation error in class declaration +features: [class, decorators, class-methods-private] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +function evaluate() { + class C { + /*{ application }*/ + get #element() {} + } +} + +assert.throws(/*{ error }*/, evaluate); diff --git a/src/decorator/getters/error/private/instance/cls-expr.template b/src/decorator/getters/error/private/instance/cls-expr.template new file mode 100644 index 00000000000..e747573e136 --- /dev/null +++ b/src/decorator/getters/error/private/instance/cls-expr.template @@ -0,0 +1,21 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/getter/error/private/instance/ +name: private getter decorator evaluation error in class expression +features: [class, decorators, class-methods-private] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +function evaluate() { + var C = class { + /*{ application }*/ + get #element() {} + } +} + +assert.throws(/*{ error }*/, evaluate); + diff --git a/src/decorator/getters/error/private/static/cls-decl.template b/src/decorator/getters/error/private/static/cls-decl.template new file mode 100644 index 00000000000..616f579be89 --- /dev/null +++ b/src/decorator/getters/error/private/static/cls-decl.template @@ -0,0 +1,21 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/getter/error/private/static/ +name: private static getter decorator evaluation error in class declaration +features: [class, decorators, class-static-methods-private] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +function evaluate() { + class C { + /*{ application }*/ + static get #element() {} + } +} + +assert.throws(/*{ error }*/, evaluate); + diff --git a/src/decorator/getters/error/private/static/cls-expr.template b/src/decorator/getters/error/private/static/cls-expr.template new file mode 100644 index 00000000000..e318451c4a5 --- /dev/null +++ b/src/decorator/getters/error/private/static/cls-expr.template @@ -0,0 +1,20 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/getter/error/private/static/ +name: private static getter decorator evaluation error in class expression +features: [class, decorators, class-static-methods-private] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +function evaluate() { + var C = class { + /*{ application }*/ + static get #element() {} + } +} + +assert.throws(/*{ error }*/, evaluate); diff --git a/src/decorator/getters/error/public/instance/cls-decl.template b/src/decorator/getters/error/public/instance/cls-decl.template new file mode 100644 index 00000000000..01271175e24 --- /dev/null +++ b/src/decorator/getters/error/public/instance/cls-decl.template @@ -0,0 +1,21 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/getter/error/public/instance/ +name: public getter decorator evaluation error in class declaration +features: [class, decorators] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +function evaluate() { + class C { + /*{ application }*/ + get element() {} + } +} + +assert.throws(/*{ error }*/, evaluate); + diff --git a/src/decorator/getters/error/public/instance/cls-expr.template b/src/decorator/getters/error/public/instance/cls-expr.template new file mode 100644 index 00000000000..07789e362d2 --- /dev/null +++ b/src/decorator/getters/error/public/instance/cls-expr.template @@ -0,0 +1,21 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/getter/error/public/instance/ +name: public getter decorator evaluation error in class expression +features: [class, decorators] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +function evaluate() { + var C = class { + /*{ application }*/ + get element() {} + } +} + +assert.throws(/*{ error }*/, evaluate); + diff --git a/src/decorator/getters/error/public/static/cls-decl.template b/src/decorator/getters/error/public/static/cls-decl.template new file mode 100644 index 00000000000..f7ebae06cdc --- /dev/null +++ b/src/decorator/getters/error/public/static/cls-decl.template @@ -0,0 +1,21 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/getter/error/public/static/ +name: public static getter decorator evaluation error in class declaration +features: [class, decorators] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +function evaluate() { + class C { + /*{ application }*/ + static get element() {} + } +} + +assert.throws(/*{ error }*/, evaluate); + diff --git a/src/decorator/getters/error/public/static/cls-expr.template b/src/decorator/getters/error/public/static/cls-expr.template new file mode 100644 index 00000000000..9675e9c0cba --- /dev/null +++ b/src/decorator/getters/error/public/static/cls-expr.template @@ -0,0 +1,20 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/getter/error/public/static/ +name: public static getter decorator evaluation error in class expression +features: [class, decorators] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +function evaluate() { + var C = class { + /*{ application }*/ + static get element() {} + } +} + +assert.throws(/*{ error }*/, evaluate); diff --git a/src/decorator/getters/standard/private/instance/cls-decl.template b/src/decorator/getters/standard/private/instance/cls-decl.template new file mode 100644 index 00000000000..0c3a04d92a4 --- /dev/null +++ b/src/decorator/getters/standard/private/instance/cls-decl.template @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/getter/private/instance/ +name: private getter decorator behavior in class declaration +features: [class, decorators, class-methods-private] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +class C { + internalValue = 123; + + /*{ application }*/ + get #element() { + return this.internalValue; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + +/*{ assertions }*/ diff --git a/src/decorator/getters/standard/private/instance/cls-expr.template b/src/decorator/getters/standard/private/instance/cls-expr.template new file mode 100644 index 00000000000..3ff6b8e5eeb --- /dev/null +++ b/src/decorator/getters/standard/private/instance/cls-expr.template @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/getter/private/instance/ +name: private getter decorator behavior in class expression +features: [class, decorators, class-methods-private] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +var C = class { + internalValue = 123; + + /*{ application }*/ + get #element() { + return this.internalValue; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + +/*{ assertions }*/ diff --git a/src/decorator/getters/standard/private/static/cls-decl.template b/src/decorator/getters/standard/private/static/cls-decl.template new file mode 100644 index 00000000000..3f443665bc4 --- /dev/null +++ b/src/decorator/getters/standard/private/static/cls-decl.template @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/getter/error/private/static/ +name: private static getter decorator behavior in class declaration +features: [class, decorators, class-static-methods-private] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +class C { + static internalValue = 123; + + /*{ application }*/ + static get #element() { + return this.internalValue; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + +/*{ assertions }*/ diff --git a/src/decorator/getters/standard/private/static/cls-expr.template b/src/decorator/getters/standard/private/static/cls-expr.template new file mode 100644 index 00000000000..7d38e595876 --- /dev/null +++ b/src/decorator/getters/standard/private/static/cls-expr.template @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/getter/error/private/static/ +name: private static getter decorator behavior in class expression +features: [class, decorators, class-static-methods-private] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +var C = class { + static internalValue = 123; + + /*{ application }*/ + static get #element() { + return this.internalValue; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + +/*{ assertions }*/ diff --git a/src/decorator/getters/standard/public/instance/cls-decl.template b/src/decorator/getters/standard/public/instance/cls-decl.template new file mode 100644 index 00000000000..cb81d8bbf5e --- /dev/null +++ b/src/decorator/getters/standard/public/instance/cls-decl.template @@ -0,0 +1,29 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/getter/public/instance/ +name: public getter decorator behavior in class declaration +features: [class, decorators] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +class C { + internalValue = 123; + + /*{ application }*/ + get element() { + return this.internalValue; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + +/*{ assertions }*/ + diff --git a/src/decorator/getters/standard/public/instance/cls-expr.template b/src/decorator/getters/standard/public/instance/cls-expr.template new file mode 100644 index 00000000000..80494437e0b --- /dev/null +++ b/src/decorator/getters/standard/public/instance/cls-expr.template @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/getter/public/instance/ +name: public getter decorator behavior in class expression +features: [class, decorators] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +var C = class { + internalValue = 123; + + /*{ application }*/ + get element() { + return this.internalValue; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + +/*{ assertions }*/ diff --git a/src/decorator/getters/standard/public/static/cls-decl.template b/src/decorator/getters/standard/public/static/cls-decl.template new file mode 100644 index 00000000000..7fa711575ae --- /dev/null +++ b/src/decorator/getters/standard/public/static/cls-decl.template @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/getter/public/static/ +name: public static getter decorator behavior in class declaration +features: [class, decorators] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +class C { + static internalValue = 123; + + /*{ application }*/ + static get element() { + return this.internalValue; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + +/*{ assertions }*/ diff --git a/src/decorator/getters/standard/public/static/cls-expr.template b/src/decorator/getters/standard/public/static/cls-expr.template new file mode 100644 index 00000000000..6eb966e576d --- /dev/null +++ b/src/decorator/getters/standard/public/static/cls-expr.template @@ -0,0 +1,28 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/getter/public/static/ +name: public static getter decorator behavior in class expression +features: [class, decorators] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +var C = class { + static internalValue = 123; + + /*{ application }*/ + static get element() { + return this.internalValue; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + +/*{ assertions }*/ diff --git a/src/decorator/method-async-deco-returns-replacement.case b/src/decorator/method-async-deco-returns-replacement.case new file mode 100644 index 00000000000..5df2cca1d62 --- /dev/null +++ b/src/decorator/method-async-deco-returns-replacement.case @@ -0,0 +1,22 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-applydecoratorstoelementdefinition +desc: Can replace a decorated method with a new method +template: methods/async/**/* +features: [decorators] +---*/ + +//- decorators +function dec(value, context) { + assert(value() instanceof Promise); + + return () => 456; +} + +//- application +@dec + +//- assertions +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/src/decorator/method-async-deco-returns-undefined.case b/src/decorator/method-async-deco-returns-undefined.case new file mode 100644 index 00000000000..2077acc3bfe --- /dev/null +++ b/src/decorator/method-async-deco-returns-undefined.case @@ -0,0 +1,26 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-applydecoratorstoelementdefinition +desc: Decorator undefined return defaults to previous value +template: methods/async/**/* +features: [decorators] +---*/ + +//- decorators +function dec1(value, context) { + assert(value() instanceof Promise); + + return () => 456; +} + +function dec2(value, context) { + assert.sameValue(value(), 456); +} + +//- application +@dec2 @dec1 + +//- assertions +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/src/decorator/method-deco-returns-invalid.case b/src/decorator/method-deco-returns-invalid.case new file mode 100644 index 00000000000..45fa6a79831 --- /dev/null +++ b/src/decorator/method-deco-returns-invalid.case @@ -0,0 +1,20 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-applydecoratorstoelementdefinition +desc: Decorator can't return an invalid value +template: methods/error/**/* +features: [decorators] +---*/ + +//- decorators +function dec(_, context) { + return 123; +} + +//- application +@dec + +//- error +TypeError diff --git a/src/decorator/method-deco-returns-replacement.case b/src/decorator/method-deco-returns-replacement.case new file mode 100644 index 00000000000..4518c8e26cc --- /dev/null +++ b/src/decorator/method-deco-returns-replacement.case @@ -0,0 +1,22 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-applydecoratorstoelementdefinition +desc: Can replace a decorated method with a new method +template: methods/standard/**/* +features: [decorators] +---*/ + +//- decorators +function dec(value, context) { + assert.sameValue(value(), 123); + + return () => 456; +} + +//- application +@dec + +//- assertions +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/src/decorator/method-deco-returns-undefined.case b/src/decorator/method-deco-returns-undefined.case new file mode 100644 index 00000000000..7c33a57b430 --- /dev/null +++ b/src/decorator/method-deco-returns-undefined.case @@ -0,0 +1,26 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-applydecoratorstoelementdefinition +desc: Decorator undefined return defaults to previous value +template: methods/standard/**/* +features: [decorators] +---*/ + +//- decorators +function dec1(value, context) { + assert.sameValue(value(), 123); + + return () => 456; +} + +function dec2(value, context) { + assert.sameValue(value(), 456); +} + +//- application +@dec2 @dec1 + +//- assertions +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/src/decorator/method-generator-deco-returns-replacement.case b/src/decorator/method-generator-deco-returns-replacement.case new file mode 100644 index 00000000000..8e18d39695e --- /dev/null +++ b/src/decorator/method-generator-deco-returns-replacement.case @@ -0,0 +1,22 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-applydecoratorstoelementdefinition +desc: Can replace a decorated method with a new method +template: methods/generator/**/* +features: [decorators] +---*/ + +//- decorators +function dec(value, context) { + assert(value() instanceof Iterator, 'value is iterator'); + + return () => 456; +} + +//- application +@dec + +//- assertions +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/src/decorator/method-generator-deco-returns-undefined.case b/src/decorator/method-generator-deco-returns-undefined.case new file mode 100644 index 00000000000..bc8c13244f8 --- /dev/null +++ b/src/decorator/method-generator-deco-returns-undefined.case @@ -0,0 +1,26 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-applydecoratorstoelementdefinition +desc: Decorator undefined return defaults to previous value +template: methods/generator/**/* +features: [decorators] +---*/ + +//- decorators +function dec1(value, context) { + assert(value() instanceof Iterator, 'value is iterator'); + + return () => 456; +} + +function dec2(value, context) { + assert.sameValue(value(), 456); +} + +//- application +@dec2 @dec1 + +//- assertions +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/src/decorator/methods/async/private/instance/cls-decl.template b/src/decorator/methods/async/private/instance/cls-decl.template new file mode 100644 index 00000000000..00dcbb03e43 --- /dev/null +++ b/src/decorator/methods/async/private/instance/cls-decl.template @@ -0,0 +1,26 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/method/async/private/instance/ +name: private method decorator behavior in class declaration +features: [class, decorators, class-methods-private] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +class C { + /*{ application }*/ + async #element() { + return 123; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + +/*{ assertions }*/ diff --git a/src/decorator/methods/async/private/instance/cls-expr.template b/src/decorator/methods/async/private/instance/cls-expr.template new file mode 100644 index 00000000000..9e76c1452f2 --- /dev/null +++ b/src/decorator/methods/async/private/instance/cls-expr.template @@ -0,0 +1,26 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/method/async/private/instance/ +name: private method decorator behavior in class expression +features: [class, decorators, class-methods-private] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +var C = class { + /*{ application }*/ + async #element() { + return 123; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + +/*{ assertions }*/ diff --git a/src/decorator/methods/async/private/static/cls-decl.template b/src/decorator/methods/async/private/static/cls-decl.template new file mode 100644 index 00000000000..6cff80efaaa --- /dev/null +++ b/src/decorator/methods/async/private/static/cls-decl.template @@ -0,0 +1,26 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/method/async/private/static/ +name: private static method decorator behavior in class declaration +features: [class, decorators, class-static-methods-private] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +class C { + /*{ application }*/ + static async #element() { + return 123; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + +/*{ assertions }*/ diff --git a/src/decorator/methods/async/private/static/cls-expr.template b/src/decorator/methods/async/private/static/cls-expr.template new file mode 100644 index 00000000000..33502ac0e29 --- /dev/null +++ b/src/decorator/methods/async/private/static/cls-expr.template @@ -0,0 +1,26 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/method/async/private/static/ +name: private static method decorator behavior in class expression +features: [class, decorators, class-static-methods-private] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +var C = class { + /*{ application }*/ + static async #element() { + return 123; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + +/*{ assertions }*/ diff --git a/src/decorator/methods/async/public/instance/cls-decl.template b/src/decorator/methods/async/public/instance/cls-decl.template new file mode 100644 index 00000000000..db24d58b48f --- /dev/null +++ b/src/decorator/methods/async/public/instance/cls-decl.template @@ -0,0 +1,27 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/method/async/public/instance/ +name: public method decorator behavior in class declaration +features: [class, decorators] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +class C { + /*{ application }*/ + async element() { + return 123; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + +/*{ assertions }*/ + diff --git a/src/decorator/methods/async/public/instance/cls-expr.template b/src/decorator/methods/async/public/instance/cls-expr.template new file mode 100644 index 00000000000..6dbc657d823 --- /dev/null +++ b/src/decorator/methods/async/public/instance/cls-expr.template @@ -0,0 +1,26 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/method/async/public/instance/ +name: public method decorator behavior in class expression +features: [class, decorators] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +var C = class { + /*{ application }*/ + async element() { + return 123; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + +/*{ assertions }*/ diff --git a/src/decorator/methods/async/public/static/cls-decl.template b/src/decorator/methods/async/public/static/cls-decl.template new file mode 100644 index 00000000000..cc162caf003 --- /dev/null +++ b/src/decorator/methods/async/public/static/cls-decl.template @@ -0,0 +1,26 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/method/async/public/static/ +name: public static method decorator behavior in class declaration +features: [class, decorators] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +class C { + /*{ application }*/ + static async element() { + return 123; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + +/*{ assertions }*/ diff --git a/src/decorator/methods/async/public/static/cls-expr.template b/src/decorator/methods/async/public/static/cls-expr.template new file mode 100644 index 00000000000..1a465db10b5 --- /dev/null +++ b/src/decorator/methods/async/public/static/cls-expr.template @@ -0,0 +1,26 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/method/async/public/static/ +name: public static method decorator behavior in class expression +features: [class, decorators] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +var C = class { + /*{ application }*/ + static async element() { + return 123; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + +/*{ assertions }*/ diff --git a/src/decorator/methods/error/private/instance/cls-decl.template b/src/decorator/methods/error/private/instance/cls-decl.template new file mode 100644 index 00000000000..e55ecd76d8e --- /dev/null +++ b/src/decorator/methods/error/private/instance/cls-decl.template @@ -0,0 +1,20 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/method/error/private/instance/ +name: private method decorator evaluation error in class declaration +features: [class, decorators, class-methods-private] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +function evaluate() { + class C { + /*{ application }*/ + #element() {} + } +} + +assert.throws(/*{ error }*/, evaluate); diff --git a/src/decorator/methods/error/private/instance/cls-expr.template b/src/decorator/methods/error/private/instance/cls-expr.template new file mode 100644 index 00000000000..21b471405c2 --- /dev/null +++ b/src/decorator/methods/error/private/instance/cls-expr.template @@ -0,0 +1,21 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/method/error/private/instance/ +name: private method decorator evaluation error in class expression +features: [class, decorators, class-methods-private] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +function evaluate() { + var C = class { + /*{ application }*/ + #element() {} + } +} + +assert.throws(/*{ error }*/, evaluate); + diff --git a/src/decorator/methods/error/private/static/cls-decl.template b/src/decorator/methods/error/private/static/cls-decl.template new file mode 100644 index 00000000000..6e174cd8ead --- /dev/null +++ b/src/decorator/methods/error/private/static/cls-decl.template @@ -0,0 +1,21 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/method/error/private/static/ +name: private static method decorator evaluation error in class declaration +features: [class, decorators, class-static-methods-private] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +function evaluate() { + class C { + /*{ application }*/ + static #element() {} + } +} + +assert.throws(/*{ error }*/, evaluate); + diff --git a/src/decorator/methods/error/private/static/cls-expr.template b/src/decorator/methods/error/private/static/cls-expr.template new file mode 100644 index 00000000000..f377f2a13e3 --- /dev/null +++ b/src/decorator/methods/error/private/static/cls-expr.template @@ -0,0 +1,20 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/method/error/private/static/ +name: private static method decorator evaluation error in class expression +features: [class, decorators, class-static-methods-private] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +function evaluate() { + var C = class { + /*{ application }*/ + static #element() {} + } +} + +assert.throws(/*{ error }*/, evaluate); diff --git a/src/decorator/methods/error/public/instance/cls-decl.template b/src/decorator/methods/error/public/instance/cls-decl.template new file mode 100644 index 00000000000..74c9f705720 --- /dev/null +++ b/src/decorator/methods/error/public/instance/cls-decl.template @@ -0,0 +1,21 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/method/error/public/instance/ +name: public method decorator evaluation error in class declaration +features: [class, decorators] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +function evaluate() { + class C { + /*{ application }*/ + element() {} + } +} + +assert.throws(/*{ error }*/, evaluate); + diff --git a/src/decorator/methods/error/public/instance/cls-expr.template b/src/decorator/methods/error/public/instance/cls-expr.template new file mode 100644 index 00000000000..9eb6bc17106 --- /dev/null +++ b/src/decorator/methods/error/public/instance/cls-expr.template @@ -0,0 +1,21 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/method/error/public/instance/ +name: public method decorator evaluation error in class expression +features: [class, decorators] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +function evaluate() { + var C = class { + /*{ application }*/ + element() {} + } +} + +assert.throws(/*{ error }*/, evaluate); + diff --git a/src/decorator/methods/error/public/static/cls-decl.template b/src/decorator/methods/error/public/static/cls-decl.template new file mode 100644 index 00000000000..35b9d52ee35 --- /dev/null +++ b/src/decorator/methods/error/public/static/cls-decl.template @@ -0,0 +1,21 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/method/error/public/static/ +name: public static method decorator evaluation error in class declaration +features: [class, decorators] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +function evaluate() { + class C { + /*{ application }*/ + static element() {} + } +} + +assert.throws(/*{ error }*/, evaluate); + diff --git a/src/decorator/methods/error/public/static/cls-expr.template b/src/decorator/methods/error/public/static/cls-expr.template new file mode 100644 index 00000000000..e1dfeda5c65 --- /dev/null +++ b/src/decorator/methods/error/public/static/cls-expr.template @@ -0,0 +1,20 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/method/error/public/static/ +name: public static method decorator evaluation error in class expression +features: [class, decorators] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +function evaluate() { + var C = class { + /*{ application }*/ + static element() {} + } +} + +assert.throws(/*{ error }*/, evaluate); diff --git a/src/decorator/methods/generator/private/instance/cls-decl.template b/src/decorator/methods/generator/private/instance/cls-decl.template new file mode 100644 index 00000000000..5a9df166ee9 --- /dev/null +++ b/src/decorator/methods/generator/private/instance/cls-decl.template @@ -0,0 +1,26 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/method/private/instance/ +name: private method decorator behavior in class declaration +features: [class, decorators, class-methods-private] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +class C { + /*{ application }*/ + * #element() { + return 123; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + +/*{ assertions }*/ diff --git a/src/decorator/methods/generator/private/instance/cls-expr.template b/src/decorator/methods/generator/private/instance/cls-expr.template new file mode 100644 index 00000000000..33346ddc632 --- /dev/null +++ b/src/decorator/methods/generator/private/instance/cls-expr.template @@ -0,0 +1,26 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/method/private/instance/ +name: private method decorator behavior in class expression +features: [class, decorators, class-methods-private] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +var C = class { + /*{ application }*/ + * #element() { + return 123; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + +/*{ assertions }*/ diff --git a/src/decorator/methods/generator/private/static/cls-decl.template b/src/decorator/methods/generator/private/static/cls-decl.template new file mode 100644 index 00000000000..d888cd9be36 --- /dev/null +++ b/src/decorator/methods/generator/private/static/cls-decl.template @@ -0,0 +1,26 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/method/private/static/ +name: private static method decorator behavior in class declaration +features: [class, decorators, class-static-methods-private] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +class C { + /*{ application }*/ + static * #element() { + return 123; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + +/*{ assertions }*/ diff --git a/src/decorator/methods/generator/private/static/cls-expr.template b/src/decorator/methods/generator/private/static/cls-expr.template new file mode 100644 index 00000000000..c220e31f33e --- /dev/null +++ b/src/decorator/methods/generator/private/static/cls-expr.template @@ -0,0 +1,26 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/method/private/static/ +name: private static method decorator behavior in class expression +features: [class, decorators, class-static-methods-private] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +var C = class { + /*{ application }*/ + static * #element() { + return 123; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + +/*{ assertions }*/ diff --git a/src/decorator/methods/generator/public/instance/cls-decl.template b/src/decorator/methods/generator/public/instance/cls-decl.template new file mode 100644 index 00000000000..3230e533dd4 --- /dev/null +++ b/src/decorator/methods/generator/public/instance/cls-decl.template @@ -0,0 +1,27 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/method/public/instance/ +name: public method decorator behavior in class declaration +features: [class, decorators] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +class C { + /*{ application }*/ + * element() { + return 123; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + +/*{ assertions }*/ + diff --git a/src/decorator/methods/generator/public/instance/cls-expr.template b/src/decorator/methods/generator/public/instance/cls-expr.template new file mode 100644 index 00000000000..cb91625a723 --- /dev/null +++ b/src/decorator/methods/generator/public/instance/cls-expr.template @@ -0,0 +1,26 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/method/public/instance/ +name: public method decorator behavior in class expression +features: [class, decorators] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +var C = class { + /*{ application }*/ + * element() { + return 123; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + +/*{ assertions }*/ diff --git a/src/decorator/methods/generator/public/static/cls-decl.template b/src/decorator/methods/generator/public/static/cls-decl.template new file mode 100644 index 00000000000..2ebbe907a2b --- /dev/null +++ b/src/decorator/methods/generator/public/static/cls-decl.template @@ -0,0 +1,26 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/method/public/static/ +name: public static method decorator behavior in class declaration +features: [class, decorators] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +class C { + /*{ application }*/ + static * element() { + return 123; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + +/*{ assertions }*/ diff --git a/src/decorator/methods/generator/public/static/cls-expr.template b/src/decorator/methods/generator/public/static/cls-expr.template new file mode 100644 index 00000000000..6e0dfc16ee1 --- /dev/null +++ b/src/decorator/methods/generator/public/static/cls-expr.template @@ -0,0 +1,26 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/method/public/static/ +name: public static method decorator behavior in class expression +features: [class, decorators] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +var C = class { + /*{ application }*/ + static * element() { + return 123; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + +/*{ assertions }*/ diff --git a/src/decorator/methods/standard/private/instance/cls-decl.template b/src/decorator/methods/standard/private/instance/cls-decl.template new file mode 100644 index 00000000000..871f878dfd4 --- /dev/null +++ b/src/decorator/methods/standard/private/instance/cls-decl.template @@ -0,0 +1,26 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/method/private/instance/ +name: private method decorator behavior in class declaration +features: [class, decorators, class-methods-private] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +class C { + /*{ application }*/ + #element() { + return 123; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + +/*{ assertions }*/ diff --git a/src/decorator/methods/standard/private/instance/cls-expr.template b/src/decorator/methods/standard/private/instance/cls-expr.template new file mode 100644 index 00000000000..87ee94ba65e --- /dev/null +++ b/src/decorator/methods/standard/private/instance/cls-expr.template @@ -0,0 +1,26 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/method/private/instance/ +name: private method decorator behavior in class expression +features: [class, decorators, class-methods-private] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +var C = class { + /*{ application }*/ + #element() { + return 123; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + +/*{ assertions }*/ diff --git a/src/decorator/methods/standard/private/static/cls-decl.template b/src/decorator/methods/standard/private/static/cls-decl.template new file mode 100644 index 00000000000..f14798c6ff7 --- /dev/null +++ b/src/decorator/methods/standard/private/static/cls-decl.template @@ -0,0 +1,26 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/method/private/static/ +name: private static method decorator behavior in class declaration +features: [class, decorators, class-static-methods-private] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +class C { + /*{ application }*/ + static #element() { + return 123; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + +/*{ assertions }*/ diff --git a/src/decorator/methods/standard/private/static/cls-expr.template b/src/decorator/methods/standard/private/static/cls-expr.template new file mode 100644 index 00000000000..eb11c7bb2c7 --- /dev/null +++ b/src/decorator/methods/standard/private/static/cls-expr.template @@ -0,0 +1,26 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/method/private/static/ +name: private static method decorator behavior in class expression +features: [class, decorators, class-static-methods-private] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +var C = class { + /*{ application }*/ + static #element() { + return 123; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + +/*{ assertions }*/ diff --git a/src/decorator/methods/standard/public/instance/cls-decl.template b/src/decorator/methods/standard/public/instance/cls-decl.template new file mode 100644 index 00000000000..2a02b7669e9 --- /dev/null +++ b/src/decorator/methods/standard/public/instance/cls-decl.template @@ -0,0 +1,27 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/method/public/instance/ +name: public method decorator behavior in class declaration +features: [class, decorators] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +class C { + /*{ application }*/ + element() { + return 123; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + +/*{ assertions }*/ + diff --git a/src/decorator/methods/standard/public/instance/cls-expr.template b/src/decorator/methods/standard/public/instance/cls-expr.template new file mode 100644 index 00000000000..2937054455d --- /dev/null +++ b/src/decorator/methods/standard/public/instance/cls-expr.template @@ -0,0 +1,26 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/method/public/instance/ +name: public method decorator behavior in class expression +features: [class, decorators] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +var C = class { + /*{ application }*/ + element() { + return 123; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + +/*{ assertions }*/ diff --git a/src/decorator/methods/standard/public/static/cls-decl.template b/src/decorator/methods/standard/public/static/cls-decl.template new file mode 100644 index 00000000000..cf54388c557 --- /dev/null +++ b/src/decorator/methods/standard/public/static/cls-decl.template @@ -0,0 +1,26 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/method/public/static/ +name: public static method decorator behavior in class declaration +features: [class, decorators] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +class C { + /*{ application }*/ + static element() { + return 123; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + +/*{ assertions }*/ diff --git a/src/decorator/methods/standard/public/static/cls-expr.template b/src/decorator/methods/standard/public/static/cls-expr.template new file mode 100644 index 00000000000..1f4e1c48bcb --- /dev/null +++ b/src/decorator/methods/standard/public/static/cls-expr.template @@ -0,0 +1,26 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/method/public/static/ +name: public static method decorator behavior in class expression +features: [class, decorators] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +var C = class { + /*{ application }*/ + static element() { + return 123; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + +/*{ assertions }*/ diff --git a/src/decorator/setter-deco-returns-invalid.case b/src/decorator/setter-deco-returns-invalid.case new file mode 100644 index 00000000000..bf4867ec8e0 --- /dev/null +++ b/src/decorator/setter-deco-returns-invalid.case @@ -0,0 +1,20 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-applydecoratorstoelementdefinition +desc: Decorator can't return an invalid value +template: setters/error/**/* +features: [decorators] +---*/ + +//- decorators +function dec(_, context) { + return 123; +} + +//- application +@dec + +//- error +TypeError diff --git a/src/decorator/setter-deco-returns-replacement.case b/src/decorator/setter-deco-returns-replacement.case new file mode 100644 index 00000000000..9413c5590c5 --- /dev/null +++ b/src/decorator/setter-deco-returns-replacement.case @@ -0,0 +1,25 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-applydecoratorstoelementdefinition +desc: Can replace a decorated setter with a new setter +template: setters/standard/**/* +features: [decorators] +---*/ + +//- decorators +function dec(set, context) { + return function (v) { + assert.sameValue(v, 456); + set.call(this, 789); + }; +} + +//- application +@dec + +//- assertions +assert.sameValue(classOrInstance.getElement(), 123); +classOrInstance.setElement(456); +assert.sameValue(classOrInstance.getElement(), 789); diff --git a/src/decorator/setter-deco-returns-undefined.case b/src/decorator/setter-deco-returns-undefined.case new file mode 100644 index 00000000000..afe4755d54c --- /dev/null +++ b/src/decorator/setter-deco-returns-undefined.case @@ -0,0 +1,31 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-applydecoratorstoelementdefinition +desc: Decorator undefined return defaults to previous value +template: setters/standard/**/* +features: [decorators] +---*/ + +//- decorators +var value; + +function dec1(set, context) { + return function (v) { + assert.sameValue(v, 456); + set.call(this, 789); + }; +} + +function dec2(value, context) { + // do nothing +} + +//- application +@dec2 @dec1 + +//- assertions +assert.sameValue(classOrInstance.getElement(), 123); +classOrInstance.setElement(456); +assert.sameValue(classOrInstance.getElement(), 789); diff --git a/src/decorator/setters/error/private/instance/cls-decl.template b/src/decorator/setters/error/private/instance/cls-decl.template new file mode 100644 index 00000000000..fbaca3dc2cc --- /dev/null +++ b/src/decorator/setters/error/private/instance/cls-decl.template @@ -0,0 +1,20 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/setter/error/private/instance/ +name: private setter decorator evaluation error in class declaration +features: [class, decorators, class-methods-private] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +function evaluate() { + class C { + /*{ application }*/ + set #element(value) {} + } +} + +assert.throws(/*{ error }*/, evaluate); diff --git a/src/decorator/setters/error/private/instance/cls-expr.template b/src/decorator/setters/error/private/instance/cls-expr.template new file mode 100644 index 00000000000..3ca3890b092 --- /dev/null +++ b/src/decorator/setters/error/private/instance/cls-expr.template @@ -0,0 +1,21 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/setter/error/private/instance/ +name: private setter decorator evaluation error in class expression +features: [class, decorators, class-methods-private] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +function evaluate() { + var C = class { + /*{ application }*/ + set #element(value) {} + } +} + +assert.throws(/*{ error }*/, evaluate); + diff --git a/src/decorator/setters/error/private/static/cls-decl.template b/src/decorator/setters/error/private/static/cls-decl.template new file mode 100644 index 00000000000..9ccc6db2d60 --- /dev/null +++ b/src/decorator/setters/error/private/static/cls-decl.template @@ -0,0 +1,21 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/setter/error/private/static/ +name: private static setter decorator evaluation error in class declaration +features: [class, decorators, class-static-methods-private] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +function evaluate() { + class C { + /*{ application }*/ + static set #element(value) {} + } +} + +assert.throws(/*{ error }*/, evaluate); + diff --git a/src/decorator/setters/error/private/static/cls-expr.template b/src/decorator/setters/error/private/static/cls-expr.template new file mode 100644 index 00000000000..742483b793d --- /dev/null +++ b/src/decorator/setters/error/private/static/cls-expr.template @@ -0,0 +1,20 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/setter/error/private/static/ +name: private static setter decorator evaluation error in class expression +features: [class, decorators, class-static-methods-private] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +function evaluate() { + var C = class { + /*{ application }*/ + static set #element(value) {} + } +} + +assert.throws(/*{ error }*/, evaluate); diff --git a/src/decorator/setters/error/public/instance/cls-decl.template b/src/decorator/setters/error/public/instance/cls-decl.template new file mode 100644 index 00000000000..7712ad059aa --- /dev/null +++ b/src/decorator/setters/error/public/instance/cls-decl.template @@ -0,0 +1,21 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/setter/error/public/instance/ +name: public setter decorator evaluation error in class declaration +features: [class, decorators] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +function evaluate() { + class C { + /*{ application }*/ + set element(value) {} + } +} + +assert.throws(/*{ error }*/, evaluate); + diff --git a/src/decorator/setters/error/public/instance/cls-expr.template b/src/decorator/setters/error/public/instance/cls-expr.template new file mode 100644 index 00000000000..935daf0a7e7 --- /dev/null +++ b/src/decorator/setters/error/public/instance/cls-expr.template @@ -0,0 +1,21 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/setter/error/public/instance/ +name: public setter decorator evaluation error in class expression +features: [class, decorators] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +function evaluate() { + var C = class { + /*{ application }*/ + set element(value) {} + } +} + +assert.throws(/*{ error }*/, evaluate); + diff --git a/src/decorator/setters/error/public/static/cls-decl.template b/src/decorator/setters/error/public/static/cls-decl.template new file mode 100644 index 00000000000..c73ac0f4de9 --- /dev/null +++ b/src/decorator/setters/error/public/static/cls-decl.template @@ -0,0 +1,21 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/setter/error/public/static/ +name: public static setter decorator evaluation error in class declaration +features: [class, decorators] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +function evaluate() { + class C { + /*{ application }*/ + static set element(value) {} + } +} + +assert.throws(/*{ error }*/, evaluate); + diff --git a/src/decorator/setters/error/public/static/cls-expr.template b/src/decorator/setters/error/public/static/cls-expr.template new file mode 100644 index 00000000000..74c1b890e55 --- /dev/null +++ b/src/decorator/setters/error/public/static/cls-expr.template @@ -0,0 +1,20 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/setter/error/public/static/ +name: public static setter decorator evaluation error in class expression +features: [class, decorators] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ + +function evaluate() { + var C = class { + /*{ application }*/ + static set element(value) {} + } +} + +assert.throws(/*{ error }*/, evaluate); diff --git a/src/decorator/setters/standard/private/instance/cls-decl.template b/src/decorator/setters/standard/private/instance/cls-decl.template new file mode 100644 index 00000000000..a722a8b720f --- /dev/null +++ b/src/decorator/setters/standard/private/instance/cls-decl.template @@ -0,0 +1,31 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/setter/private/instance/ +name: private setter decorator behavior in class declaration +features: [class, decorators, class-methods-private] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ +class C { + internalValue = 123; + + /*{ application }*/ + set #element(value) { + this.internalValue = value; + } + + getElement() { + return this.internalValue; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +/*{ assertions }*/ diff --git a/src/decorator/setters/standard/private/instance/cls-expr.template b/src/decorator/setters/standard/private/instance/cls-expr.template new file mode 100644 index 00000000000..cdfd9c8ca63 --- /dev/null +++ b/src/decorator/setters/standard/private/instance/cls-expr.template @@ -0,0 +1,31 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/setter/private/instance/ +name: private setter decorator behavior in class expression +features: [class, decorators, class-methods-private] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ +var C = class { + internalValue = 123; + + /*{ application }*/ + set #element(value) { + this.internalValue = value; + } + + getElement() { + return this.internalValue; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +/*{ assertions }*/ diff --git a/src/decorator/setters/standard/private/static/cls-decl.template b/src/decorator/setters/standard/private/static/cls-decl.template new file mode 100644 index 00000000000..f7f81037f7e --- /dev/null +++ b/src/decorator/setters/standard/private/static/cls-decl.template @@ -0,0 +1,31 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/setter/private/static/ +name: private static setter decorator behavior in class declaration +features: [class, decorators, class-static-methods-private] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ +class C { + static internalValue = 123; + + /*{ application }*/ + static set #element(value) { + this.internalValue = value; + } + + static getElement() { + return this.internalValue; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +/*{ assertions }*/ diff --git a/src/decorator/setters/standard/private/static/cls-expr.template b/src/decorator/setters/standard/private/static/cls-expr.template new file mode 100644 index 00000000000..65e0051fdaf --- /dev/null +++ b/src/decorator/setters/standard/private/static/cls-expr.template @@ -0,0 +1,31 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/setter/private/static/ +name: private static setter decorator behavior in class expression +features: [class, decorators, class-static-methods-private] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ +var C = class { + static internalValue = 123; + + /*{ application }*/ + static set #element(value) { + this.internalValue = value; + } + + static getElement() { + return this.internalValue; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +/*{ assertions }*/ diff --git a/src/decorator/setters/standard/public/instance/cls-decl.template b/src/decorator/setters/standard/public/instance/cls-decl.template new file mode 100644 index 00000000000..4510799749d --- /dev/null +++ b/src/decorator/setters/standard/public/instance/cls-decl.template @@ -0,0 +1,32 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/setter/public/instance/ +name: public setter decorator behavior in class declaration +features: [class, decorators] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ +class C { + internalValue = 123; + + /*{ application }*/ + set element(value) { + this.internalValue = value; + } + + getElement() { + return this.internalValue; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +/*{ assertions }*/ + diff --git a/src/decorator/setters/standard/public/instance/cls-expr.template b/src/decorator/setters/standard/public/instance/cls-expr.template new file mode 100644 index 00000000000..698c51e3de4 --- /dev/null +++ b/src/decorator/setters/standard/public/instance/cls-expr.template @@ -0,0 +1,31 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/setter/public/instance/ +name: public setter decorator behavior in class expression +features: [class, decorators] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ +var C = class { + internalValue = 123; + + /*{ application }*/ + set element(value) { + this.internalValue = value; + } + + getElement() { + return this.internalValue; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +/*{ assertions }*/ diff --git a/src/decorator/setters/standard/public/static/cls-decl.template b/src/decorator/setters/standard/public/static/cls-decl.template new file mode 100644 index 00000000000..cc7a2a6ce82 --- /dev/null +++ b/src/decorator/setters/standard/public/static/cls-decl.template @@ -0,0 +1,31 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/decorator/setter/public/static/ +name: public static setter decorator behavior in class declaration +features: [class, decorators] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ +class C { + static internalValue = 123; + + /*{ application }*/ + static set element(value) { + this.internalValue = value; + } + + static getElement() { + return this.internalValue; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +/*{ assertions }*/ diff --git a/src/decorator/setters/standard/public/static/cls-expr.template b/src/decorator/setters/standard/public/static/cls-expr.template new file mode 100644 index 00000000000..188a6a181ec --- /dev/null +++ b/src/decorator/setters/standard/public/static/cls-expr.template @@ -0,0 +1,31 @@ +// Copyright (C) 2024 Kristen Maevyn Hewell Garrett. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/decorator/setter/public/static/ +name: public static setter decorator behavior in class expression +features: [class, decorators] +esid: prod-MethodDefinition +---*/ + +/*{ decorators }*/ +var C = class { + static internalValue = 123; + + /*{ application }*/ + static set element(value) { + this.internalValue = value; + } + + static getElement() { + return this.internalValue; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +/*{ assertions }*/ From f02d60694c1c63fa7b410beab713a5b2435059e4 Mon Sep 17 00:00:00 2001 From: Kristen Maevyn Date: Thu, 6 Jun 2024 09:48:10 -0400 Subject: [PATCH 2/3] Autogenerated tests --- .../accessor-deco-invalid-return-get.js | 28 +++++ .../accessor-deco-invalid-return-init.js | 28 +++++ .../accessor-deco-invalid-return-set.js | 28 +++++ .../instance/accessor-deco-invalid-return.js | 26 +++++ .../accessor-deco-invalid-return-get.js | 27 +++++ .../accessor-deco-invalid-return-init.js | 27 +++++ .../accessor-deco-invalid-return-set.js | 27 +++++ .../static/accessor-deco-invalid-return.js | 25 +++++ .../accessor-deco-invalid-return-get.js | 28 +++++ .../accessor-deco-invalid-return-init.js | 28 +++++ .../accessor-deco-invalid-return-set.js | 28 +++++ .../instance/accessor-deco-invalid-return.js | 26 +++++ .../instance/accessor-deco-returns-get.js | 38 +++++++ .../instance/accessor-deco-returns-init.js | 40 +++++++ .../instance/accessor-deco-returns-set.js | 40 +++++++ .../private/instance/context-access-get.js | 35 ++++++ .../private/instance/context-access-set.js | 36 +++++++ .../private/instance/context-kind-accessor.js | 32 ++++++ .../private/instance/context-name-private.js | 32 ++++++ .../private/instance/context-private-false.js | 32 ++++++ .../private/instance/context-static-false.js | 32 ++++++ .../instance/field-and-accessor-init-this.js | 39 +++++++ .../static/accessor-deco-returns-get.js | 38 +++++++ .../static/accessor-deco-returns-init.js | 40 +++++++ .../static/accessor-deco-returns-set.js | 40 +++++++ .../private/static/context-access-get.js | 35 ++++++ .../private/static/context-access-set.js | 36 +++++++ .../private/static/context-kind-accessor.js | 32 ++++++ .../private/static/context-name-private.js | 32 ++++++ .../private/static/context-private-false.js | 32 ++++++ .../private/static/context-static-true.js | 32 ++++++ .../static/field-and-accessor-init-this.js | 39 +++++++ .../instance/accessor-deco-returns-get.js | 38 +++++++ .../instance/accessor-deco-returns-init.js | 40 +++++++ .../instance/accessor-deco-returns-set.js | 40 +++++++ .../public/instance/context-access-get.js | 35 ++++++ .../public/instance/context-access-set.js | 36 +++++++ .../public/instance/context-kind-accessor.js | 32 ++++++ .../public/instance/context-name-public.js | 32 ++++++ .../public/instance/context-private-true.js | 32 ++++++ .../public/instance/context-static-false.js | 32 ++++++ .../instance/field-and-accessor-init-this.js | 39 +++++++ .../accessor-deco-invalid-return-get.js | 27 +++++ .../accessor-deco-invalid-return-init.js | 27 +++++ .../accessor-deco-invalid-return-set.js | 27 +++++ .../static/accessor-deco-invalid-return.js | 25 +++++ .../static/accessor-deco-returns-get.js | 38 +++++++ .../static/accessor-deco-returns-init.js | 40 +++++++ .../static/accessor-deco-returns-set.js | 40 +++++++ .../public/static/context-access-get.js | 35 ++++++ .../public/static/context-access-set.js | 36 +++++++ .../public/static/context-kind-accessor.js | 32 ++++++ .../public/static/context-name-public.js | 32 ++++++ .../public/static/context-private-true.js | 32 ++++++ .../public/static/context-static-true.js | 32 ++++++ .../static/field-and-accessor-init-this.js | 39 +++++++ .../accessor-with-init-deco-returns-get.js | 39 +++++++ .../accessor-with-init-deco-returns-init.js | 41 +++++++ .../accessor-with-init-deco-returns-set.js | 41 +++++++ .../private/instance/context-access-get.js | 36 +++++++ .../private/instance/context-access-set.js | 37 +++++++ ...or-order-application-field-and-accessor.js | 51 +++++++++ .../instance/field-and-accessor-init-this.js | 40 +++++++ .../accessor-with-init-deco-returns-get.js | 39 +++++++ .../accessor-with-init-deco-returns-init.js | 41 +++++++ .../accessor-with-init-deco-returns-set.js | 41 +++++++ .../private/static/context-access-get.js | 36 +++++++ .../private/static/context-access-set.js | 37 +++++++ ...or-order-application-field-and-accessor.js | 51 +++++++++ .../static/field-and-accessor-init-this.js | 40 +++++++ .../accessor-with-init-deco-returns-get.js | 39 +++++++ .../accessor-with-init-deco-returns-init.js | 41 +++++++ .../accessor-with-init-deco-returns-set.js | 41 +++++++ .../public/instance/context-access-get.js | 36 +++++++ .../public/instance/context-access-set.js | 37 +++++++ ...or-order-application-field-and-accessor.js | 51 +++++++++ .../instance/field-and-accessor-init-this.js | 40 +++++++ .../accessor-with-init-deco-returns-get.js | 39 +++++++ .../accessor-with-init-deco-returns-init.js | 41 +++++++ .../accessor-with-init-deco-returns-set.js | 41 +++++++ .../public/static/context-access-get.js | 36 +++++++ .../public/static/context-access-set.js | 37 +++++++ ...or-order-application-field-and-accessor.js | 51 +++++++++ .../static/field-and-accessor-init-this.js | 40 +++++++ .../class/class-deco-returns-class.js | 35 ++++++ .../class/class-deco-returns-function.js | 25 +++++ .../class/class-deco-returns-proxy.js | 33 ++++++ .../class/class-deco-returns-subclass.js | 36 +++++++ .../decorator/class/context-kind-class.js | 21 ++++ .../decorator/class/context-name-class.js | 21 ++++ ...ator-order-application-method-and-class.js | 29 +++++ ...decorator-order-phases-1-pre-definition.js | 71 ++++++++++++ .../decorator-order-phases-2-application.js | 78 ++++++++++++++ .../decorator-order-phases-3-init-static.js | 101 +++++++++++++++++ .../decorator/class/decorator-order-phases.js | 74 +++++++++++++ .../error/class-deco-invalid-return-arrow.js | 26 +++++ .../class-deco-invalid-return-primitive.js | 26 +++++ .../decorator-order-phases-4-init-instance.js | 88 +++++++++++++++ .../instance/field-deco-invalid-return.js | 26 +++++ .../static/field-deco-invalid-return.js | 25 +++++ .../instance/field-deco-invalid-return.js | 26 +++++ .../private/instance/context-access-set.js | 36 +++++++ .../private/instance/context-kind-field.js | 32 ++++++ .../private/instance/context-name-private.js | 32 ++++++ .../private/instance/context-private-false.js | 32 ++++++ .../private/instance/context-static-false.js | 32 ++++++ .../instance/field-and-accessor-init-this.js | 39 +++++++ .../field-deco-returns-initializer.js | 36 +++++++ .../instance/field-deco-returns-undefined.js | 33 ++++++ .../private/static/context-access-set.js | 36 +++++++ .../private/static/context-kind-field.js | 32 ++++++ .../private/static/context-name-private.js | 32 ++++++ .../private/static/context-private-false.js | 32 ++++++ .../private/static/context-static-true.js | 32 ++++++ .../static/field-and-accessor-init-this.js | 39 +++++++ .../static/field-deco-returns-initializer.js | 36 +++++++ .../static/field-deco-returns-undefined.js | 33 ++++++ .../public/instance/context-access-set.js | 36 +++++++ .../public/instance/context-kind-field.js | 32 ++++++ .../public/instance/context-name-public.js | 32 ++++++ .../public/instance/context-private-true.js | 32 ++++++ .../public/instance/context-static-false.js | 32 ++++++ .../instance/field-and-accessor-init-this.js | 39 +++++++ .../field-deco-returns-initializer.js | 36 +++++++ .../instance/field-deco-returns-undefined.js | 33 ++++++ .../field/public/static/context-access-set.js | 36 +++++++ .../field/public/static/context-kind-field.js | 32 ++++++ .../public/static/context-name-public.js | 32 ++++++ .../public/static/context-private-true.js | 32 ++++++ .../public/static/context-static-true.js | 32 ++++++ .../static/field-and-accessor-init-this.js | 39 +++++++ .../static/field-deco-invalid-return.js | 25 +++++ .../static/field-deco-returns-initializer.js | 36 +++++++ .../static/field-deco-returns-undefined.js | 33 ++++++ .../private/instance/context-access-get.js | 36 +++++++ .../private/instance/context-access-set.js | 37 +++++++ ...or-order-application-field-and-accessor.js | 51 +++++++++ .../instance/field-and-accessor-init-this.js | 40 +++++++ .../instance/field-receives-undefined.js | 33 ++++++ ...ield-with-init-deco-returns-initializer.js | 42 ++++++++ .../field-with-init-deco-returns-undefined.js | 39 +++++++ .../private/static/context-access-get.js | 36 +++++++ .../private/static/context-access-set.js | 37 +++++++ ...or-order-application-field-and-accessor.js | 51 +++++++++ .../static/field-and-accessor-init-this.js | 40 +++++++ .../static/field-receives-undefined.js | 33 ++++++ ...ield-with-init-deco-returns-initializer.js | 42 ++++++++ .../field-with-init-deco-returns-undefined.js | 39 +++++++ .../public/instance/context-access-get.js | 36 +++++++ .../public/instance/context-access-set.js | 37 +++++++ ...or-order-application-field-and-accessor.js | 51 +++++++++ .../instance/field-and-accessor-init-this.js | 40 +++++++ .../instance/field-receives-undefined.js | 33 ++++++ ...ield-with-init-deco-returns-initializer.js | 42 ++++++++ .../field-with-init-deco-returns-undefined.js | 39 +++++++ .../public/static/context-access-get.js | 36 +++++++ .../public/static/context-access-set.js | 37 +++++++ ...or-order-application-field-and-accessor.js | 51 +++++++++ .../static/field-and-accessor-init-this.js | 40 +++++++ .../public/static/field-receives-undefined.js | 33 ++++++ ...ield-with-init-deco-returns-initializer.js | 42 ++++++++ .../field-with-init-deco-returns-undefined.js | 39 +++++++ .../instance/getter-deco-returns-invalid.js | 26 +++++ .../private/static/context-kind-getter.js | 32 ++++++ .../private/static/context-name-private.js | 32 ++++++ .../private/static/context-private-false.js | 32 ++++++ .../private/static/context-static-true.js | 32 ++++++ .../static/getter-deco-returns-invalid.js | 25 +++++ .../static/getter-deco-returns-replacement.js | 38 +++++++ .../static/getter-deco-returns-undefined.js | 39 +++++++ .../instance/getter-deco-returns-invalid.js | 26 +++++ .../static/getter-deco-returns-invalid.js | 25 +++++ .../private/instance/context-kind-getter.js | 32 ++++++ .../private/instance/context-name-private.js | 32 ++++++ .../private/instance/context-private-false.js | 32 ++++++ .../private/instance/context-static-false.js | 32 ++++++ .../getter-deco-returns-replacement.js | 38 +++++++ .../instance/getter-deco-returns-undefined.js | 39 +++++++ .../public/instance/context-kind-getter.js | 32 ++++++ .../public/instance/context-name-public.js | 32 ++++++ .../public/instance/context-private-true.js | 32 ++++++ .../public/instance/context-static-false.js | 32 ++++++ .../getter-deco-returns-replacement.js | 38 +++++++ .../instance/getter-deco-returns-undefined.js | 39 +++++++ .../public/static/context-kind-getter.js | 32 ++++++ .../public/static/context-name-public.js | 32 ++++++ .../public/static/context-private-true.js | 32 ++++++ .../public/static/context-static-true.js | 32 ++++++ .../static/getter-deco-returns-replacement.js | 38 +++++++ .../static/getter-deco-returns-undefined.js | 39 +++++++ .../private/instance/context-kind-method.js | 30 ++++++ .../method-async-deco-returns-replacement.js | 33 ++++++ .../method-async-deco-returns-undefined.js | 37 +++++++ .../private/static/context-kind-method.js | 30 ++++++ .../method-async-deco-returns-replacement.js | 33 ++++++ .../method-async-deco-returns-undefined.js | 37 +++++++ .../public/instance/context-kind-method.js | 30 ++++++ .../method-async-deco-returns-replacement.js | 33 ++++++ .../method-async-deco-returns-undefined.js | 37 +++++++ .../public/static/context-kind-method.js | 30 ++++++ .../method-async-deco-returns-replacement.js | 33 ++++++ .../method-async-deco-returns-undefined.js | 37 +++++++ .../instance/method-deco-returns-invalid.js | 26 +++++ .../static/method-deco-returns-invalid.js | 25 +++++ .../instance/method-deco-returns-invalid.js | 26 +++++ .../static/method-deco-returns-invalid.js | 25 +++++ .../private/instance/context-access-get.js | 33 ++++++ .../private/instance/context-kind-method.js | 30 ++++++ .../private/instance/context-name-private.js | 30 ++++++ .../private/instance/context-private-false.js | 30 ++++++ .../private/instance/context-static-false.js | 30 ++++++ ...ator-order-application-method-and-class.js | 38 +++++++ .../method-deco-returns-replacement.js | 33 ++++++ .../instance/method-deco-returns-undefined.js | 37 +++++++ ...thod-generator-deco-returns-replacement.js | 33 ++++++ ...method-generator-deco-returns-undefined.js | 37 +++++++ .../private/static/context-access-get.js | 33 ++++++ .../private/static/context-kind-method.js | 30 ++++++ .../private/static/context-name-private.js | 30 ++++++ .../private/static/context-private-false.js | 30 ++++++ .../private/static/context-static-true.js | 30 ++++++ ...ator-order-application-method-and-class.js | 38 +++++++ .../static/method-deco-returns-replacement.js | 33 ++++++ .../static/method-deco-returns-undefined.js | 37 +++++++ ...thod-generator-deco-returns-replacement.js | 33 ++++++ ...method-generator-deco-returns-undefined.js | 37 +++++++ .../public/instance/context-access-get.js | 33 ++++++ .../public/instance/context-kind-method.js | 30 ++++++ .../public/instance/context-name-public.js | 30 ++++++ .../public/instance/context-private-true.js | 30 ++++++ .../public/instance/context-static-false.js | 30 ++++++ ...ator-order-application-method-and-class.js | 38 +++++++ .../method-deco-returns-replacement.js | 33 ++++++ .../instance/method-deco-returns-undefined.js | 37 +++++++ ...thod-generator-deco-returns-replacement.js | 33 ++++++ ...method-generator-deco-returns-undefined.js | 37 +++++++ .../public/static/context-access-get.js | 33 ++++++ .../public/static/context-kind-method.js | 30 ++++++ .../public/static/context-name-public.js | 30 ++++++ .../public/static/context-private-true.js | 30 ++++++ .../public/static/context-static-true.js | 30 ++++++ ...ator-order-application-method-and-class.js | 38 +++++++ .../static/method-deco-returns-replacement.js | 33 ++++++ .../static/method-deco-returns-undefined.js | 37 +++++++ ...thod-generator-deco-returns-replacement.js | 33 ++++++ ...method-generator-deco-returns-undefined.js | 37 +++++++ .../instance/setter-deco-returns-invalid.js | 26 +++++ .../static/setter-deco-returns-invalid.js | 25 +++++ .../instance/setter-deco-returns-invalid.js | 26 +++++ .../static/setter-deco-returns-invalid.js | 25 +++++ .../private/instance/context-access-set.js | 39 +++++++ .../private/instance/context-kind-setter.js | 35 ++++++ .../private/instance/context-name-private.js | 35 ++++++ .../private/instance/context-private-false.js | 35 ++++++ .../private/instance/context-static-false.js | 35 ++++++ .../setter-deco-returns-replacement.js | 41 +++++++ .../instance/setter-deco-returns-undefined.js | 47 ++++++++ .../private/static/context-access-set.js | 39 +++++++ .../private/static/context-kind-setter.js | 35 ++++++ .../private/static/context-name-private.js | 35 ++++++ .../private/static/context-private-false.js | 35 ++++++ .../private/static/context-static-true.js | 35 ++++++ .../static/setter-deco-returns-replacement.js | 41 +++++++ .../static/setter-deco-returns-undefined.js | 47 ++++++++ .../public/instance/context-access-set.js | 39 +++++++ .../public/instance/context-kind-setter.js | 35 ++++++ .../public/instance/context-name-public.js | 35 ++++++ .../public/instance/context-private-true.js | 35 ++++++ .../public/instance/context-static-false.js | 35 ++++++ .../setter-deco-returns-replacement.js | 41 +++++++ .../instance/setter-deco-returns-undefined.js | 47 ++++++++ .../public/static/context-access-set.js | 39 +++++++ .../public/static/context-kind-setter.js | 35 ++++++ .../public/static/context-name-public.js | 35 ++++++ .../public/static/context-private-true.js | 35 ++++++ .../public/static/context-static-true.js | 35 ++++++ .../static/setter-deco-returns-replacement.js | 41 +++++++ .../static/setter-deco-returns-undefined.js | 47 ++++++++ .../accessor-deco-invalid-return-get.js | 27 +++++ .../accessor-deco-invalid-return-init.js | 27 +++++ .../accessor-deco-invalid-return-set.js | 27 +++++ .../instance/accessor-deco-invalid-return.js | 25 +++++ .../accessor-deco-invalid-return-get.js | 28 +++++ .../accessor-deco-invalid-return-init.js | 28 +++++ .../accessor-deco-invalid-return-set.js | 28 +++++ .../static/accessor-deco-invalid-return.js | 26 +++++ .../accessor-deco-invalid-return-get.js | 28 +++++ .../accessor-deco-invalid-return-init.js | 28 +++++ .../accessor-deco-invalid-return-set.js | 28 +++++ .../instance/accessor-deco-invalid-return.js | 26 +++++ .../instance/accessor-deco-returns-get.js | 38 +++++++ .../instance/accessor-deco-returns-init.js | 40 +++++++ .../instance/accessor-deco-returns-set.js | 40 +++++++ .../private/instance/context-access-get.js | 35 ++++++ .../private/instance/context-access-set.js | 36 +++++++ .../private/instance/context-kind-accessor.js | 32 ++++++ .../private/instance/context-name-private.js | 32 ++++++ .../private/instance/context-private-false.js | 32 ++++++ .../private/instance/context-static-false.js | 32 ++++++ .../instance/field-and-accessor-init-this.js | 39 +++++++ .../static/accessor-deco-returns-get.js | 38 +++++++ .../static/accessor-deco-returns-init.js | 40 +++++++ .../static/accessor-deco-returns-set.js | 40 +++++++ .../private/static/context-access-get.js | 35 ++++++ .../private/static/context-access-set.js | 36 +++++++ .../private/static/context-kind-accessor.js | 32 ++++++ .../private/static/context-name-private.js | 32 ++++++ .../private/static/context-private-false.js | 32 ++++++ .../private/static/context-static-true.js | 32 ++++++ .../static/field-and-accessor-init-this.js | 39 +++++++ .../instance/accessor-deco-returns-get.js | 38 +++++++ .../instance/accessor-deco-returns-init.js | 40 +++++++ .../instance/accessor-deco-returns-set.js | 40 +++++++ .../public/instance/context-access-get.js | 35 ++++++ .../public/instance/context-access-set.js | 36 +++++++ .../public/instance/context-kind-accessor.js | 32 ++++++ .../public/instance/context-name-public.js | 32 ++++++ .../public/instance/context-private-true.js | 32 ++++++ .../public/instance/context-static-false.js | 32 ++++++ .../instance/field-and-accessor-init-this.js | 39 +++++++ .../accessor-deco-invalid-return-get.js | 28 +++++ .../accessor-deco-invalid-return-init.js | 28 +++++ .../accessor-deco-invalid-return-set.js | 28 +++++ .../static/accessor-deco-invalid-return.js | 26 +++++ .../static/accessor-deco-returns-get.js | 38 +++++++ .../static/accessor-deco-returns-init.js | 40 +++++++ .../static/accessor-deco-returns-set.js | 40 +++++++ .../public/static/context-access-get.js | 35 ++++++ .../public/static/context-access-set.js | 36 +++++++ .../public/static/context-kind-accessor.js | 32 ++++++ .../public/static/context-name-public.js | 32 ++++++ .../public/static/context-private-true.js | 32 ++++++ .../public/static/context-static-true.js | 32 ++++++ .../static/field-and-accessor-init-this.js | 39 +++++++ .../accessor-with-init-deco-returns-get.js | 39 +++++++ .../accessor-with-init-deco-returns-init.js | 41 +++++++ .../accessor-with-init-deco-returns-set.js | 41 +++++++ .../private/instance/context-access-get.js | 36 +++++++ .../private/instance/context-access-set.js | 37 +++++++ ...or-order-application-field-and-accessor.js | 51 +++++++++ .../instance/field-and-accessor-init-this.js | 40 +++++++ .../accessor-with-init-deco-returns-get.js | 39 +++++++ .../accessor-with-init-deco-returns-init.js | 41 +++++++ .../accessor-with-init-deco-returns-set.js | 41 +++++++ .../private/static/context-access-get.js | 36 +++++++ .../private/static/context-access-set.js | 37 +++++++ ...or-order-application-field-and-accessor.js | 51 +++++++++ .../static/field-and-accessor-init-this.js | 40 +++++++ .../accessor-with-init-deco-returns-get.js | 39 +++++++ .../accessor-with-init-deco-returns-init.js | 41 +++++++ .../accessor-with-init-deco-returns-set.js | 41 +++++++ .../public/instance/context-access-get.js | 36 +++++++ .../public/instance/context-access-set.js | 37 +++++++ ...or-order-application-field-and-accessor.js | 51 +++++++++ .../instance/field-and-accessor-init-this.js | 40 +++++++ .../accessor-with-init-deco-returns-get.js | 39 +++++++ .../accessor-with-init-deco-returns-init.js | 41 +++++++ .../accessor-with-init-deco-returns-set.js | 41 +++++++ .../public/static/context-access-get.js | 36 +++++++ .../public/static/context-access-set.js | 37 +++++++ ...or-order-application-field-and-accessor.js | 51 +++++++++ .../static/field-and-accessor-init-this.js | 40 +++++++ .../class/class-deco-rebinds-identifier.js | 33 ++++++ .../class/class-deco-returns-class.js | 36 +++++++ .../class/class-deco-returns-function.js | 26 +++++ .../class/class-deco-returns-proxy.js | 34 ++++++ .../class/class-deco-returns-subclass.js | 37 +++++++ .../decorator/class/context-kind-class.js | 22 ++++ .../decorator/class/context-name-class.js | 22 ++++ ...ator-order-application-method-and-class.js | 30 ++++++ ...decorator-order-phases-1-pre-definition.js | 72 +++++++++++++ .../decorator-order-phases-2-application.js | 79 ++++++++++++++ .../decorator-order-phases-3-init-static.js | 102 ++++++++++++++++++ .../decorator/class/decorator-order-phases.js | 75 +++++++++++++ .../error/class-deco-invalid-return-arrow.js | 23 ++++ .../class-deco-invalid-return-primitive.js | 23 ++++ .../decorator-order-phases-4-init-instance.js | 89 +++++++++++++++ .../instance/field-deco-invalid-return.js | 25 +++++ .../static/field-deco-invalid-return.js | 26 +++++ .../instance/field-deco-invalid-return.js | 26 +++++ .../private/instance/context-access-set.js | 36 +++++++ .../private/instance/context-kind-field.js | 32 ++++++ .../private/instance/context-name-private.js | 32 ++++++ .../private/instance/context-private-false.js | 32 ++++++ .../private/instance/context-static-false.js | 32 ++++++ .../instance/field-and-accessor-init-this.js | 39 +++++++ .../field-deco-returns-initializer.js | 36 +++++++ .../instance/field-deco-returns-undefined.js | 33 ++++++ .../private/static/context-access-set.js | 36 +++++++ .../private/static/context-kind-field.js | 32 ++++++ .../private/static/context-name-private.js | 32 ++++++ .../private/static/context-private-false.js | 32 ++++++ .../private/static/context-static-true.js | 32 ++++++ .../static/field-and-accessor-init-this.js | 39 +++++++ .../static/field-deco-returns-initializer.js | 36 +++++++ .../static/field-deco-returns-undefined.js | 33 ++++++ .../public/instance/context-access-set.js | 36 +++++++ .../public/instance/context-kind-field.js | 32 ++++++ .../public/instance/context-name-public.js | 32 ++++++ .../public/instance/context-private-true.js | 32 ++++++ .../public/instance/context-static-false.js | 32 ++++++ .../instance/field-and-accessor-init-this.js | 39 +++++++ .../field-deco-returns-initializer.js | 36 +++++++ .../instance/field-deco-returns-undefined.js | 33 ++++++ .../field/public/static/context-access-set.js | 36 +++++++ .../field/public/static/context-kind-field.js | 32 ++++++ .../public/static/context-name-public.js | 32 ++++++ .../public/static/context-private-true.js | 32 ++++++ .../public/static/context-static-true.js | 32 ++++++ .../static/field-and-accessor-init-this.js | 39 +++++++ .../static/field-deco-invalid-return.js | 26 +++++ .../static/field-deco-returns-initializer.js | 36 +++++++ .../static/field-deco-returns-undefined.js | 33 ++++++ .../private/instance/context-access-get.js | 36 +++++++ .../private/instance/context-access-set.js | 37 +++++++ ...or-order-application-field-and-accessor.js | 51 +++++++++ .../instance/field-and-accessor-init-this.js | 40 +++++++ .../instance/field-receives-undefined.js | 33 ++++++ ...ield-with-init-deco-returns-initializer.js | 42 ++++++++ .../field-with-init-deco-returns-undefined.js | 39 +++++++ .../private/static/context-access-get.js | 36 +++++++ .../private/static/context-access-set.js | 37 +++++++ ...or-order-application-field-and-accessor.js | 51 +++++++++ .../static/field-and-accessor-init-this.js | 40 +++++++ .../static/field-receives-undefined.js | 33 ++++++ ...ield-with-init-deco-returns-initializer.js | 42 ++++++++ .../field-with-init-deco-returns-undefined.js | 39 +++++++ .../public/instance/context-access-get.js | 36 +++++++ .../public/instance/context-access-set.js | 37 +++++++ ...or-order-application-field-and-accessor.js | 51 +++++++++ .../instance/field-and-accessor-init-this.js | 40 +++++++ .../instance/field-receives-undefined.js | 33 ++++++ ...ield-with-init-deco-returns-initializer.js | 42 ++++++++ .../field-with-init-deco-returns-undefined.js | 39 +++++++ .../public/static/context-access-get.js | 36 +++++++ .../public/static/context-access-set.js | 37 +++++++ ...or-order-application-field-and-accessor.js | 51 +++++++++ .../static/field-and-accessor-init-this.js | 40 +++++++ .../public/static/field-receives-undefined.js | 33 ++++++ ...ield-with-init-deco-returns-initializer.js | 42 ++++++++ .../field-with-init-deco-returns-undefined.js | 39 +++++++ .../instance/getter-deco-returns-invalid.js | 25 +++++ .../private/static/context-kind-getter.js | 32 ++++++ .../private/static/context-name-private.js | 32 ++++++ .../private/static/context-private-false.js | 32 ++++++ .../private/static/context-static-true.js | 32 ++++++ .../static/getter-deco-returns-invalid.js | 26 +++++ .../static/getter-deco-returns-replacement.js | 38 +++++++ .../static/getter-deco-returns-undefined.js | 39 +++++++ .../instance/getter-deco-returns-invalid.js | 26 +++++ .../static/getter-deco-returns-invalid.js | 26 +++++ .../private/instance/context-kind-getter.js | 32 ++++++ .../private/instance/context-name-private.js | 32 ++++++ .../private/instance/context-private-false.js | 32 ++++++ .../private/instance/context-static-false.js | 32 ++++++ .../getter-deco-returns-replacement.js | 38 +++++++ .../instance/getter-deco-returns-undefined.js | 39 +++++++ .../public/instance/context-kind-getter.js | 33 ++++++ .../public/instance/context-name-public.js | 33 ++++++ .../public/instance/context-private-true.js | 33 ++++++ .../public/instance/context-static-false.js | 33 ++++++ .../getter-deco-returns-replacement.js | 39 +++++++ .../instance/getter-deco-returns-undefined.js | 40 +++++++ .../public/static/context-kind-getter.js | 32 ++++++ .../public/static/context-name-public.js | 32 ++++++ .../public/static/context-private-true.js | 32 ++++++ .../public/static/context-static-true.js | 32 ++++++ .../static/getter-deco-returns-replacement.js | 38 +++++++ .../static/getter-deco-returns-undefined.js | 39 +++++++ .../private/instance/context-kind-method.js | 30 ++++++ .../method-async-deco-returns-replacement.js | 33 ++++++ .../method-async-deco-returns-undefined.js | 37 +++++++ .../private/static/context-kind-method.js | 30 ++++++ .../method-async-deco-returns-replacement.js | 33 ++++++ .../method-async-deco-returns-undefined.js | 37 +++++++ .../public/instance/context-kind-method.js | 31 ++++++ .../method-async-deco-returns-replacement.js | 34 ++++++ .../method-async-deco-returns-undefined.js | 38 +++++++ .../public/static/context-kind-method.js | 30 ++++++ .../method-async-deco-returns-replacement.js | 33 ++++++ .../method-async-deco-returns-undefined.js | 37 +++++++ .../instance/method-deco-returns-invalid.js | 25 +++++ .../static/method-deco-returns-invalid.js | 26 +++++ .../instance/method-deco-returns-invalid.js | 26 +++++ .../static/method-deco-returns-invalid.js | 26 +++++ .../private/instance/context-access-get.js | 33 ++++++ .../private/instance/context-kind-method.js | 30 ++++++ .../private/instance/context-name-private.js | 30 ++++++ .../private/instance/context-private-false.js | 30 ++++++ .../private/instance/context-static-false.js | 30 ++++++ ...ator-order-application-method-and-class.js | 38 +++++++ .../method-deco-returns-replacement.js | 33 ++++++ .../instance/method-deco-returns-undefined.js | 37 +++++++ ...thod-generator-deco-returns-replacement.js | 33 ++++++ ...method-generator-deco-returns-undefined.js | 37 +++++++ .../private/static/context-access-get.js | 33 ++++++ .../private/static/context-kind-method.js | 30 ++++++ .../private/static/context-name-private.js | 30 ++++++ .../private/static/context-private-false.js | 30 ++++++ .../private/static/context-static-true.js | 30 ++++++ ...ator-order-application-method-and-class.js | 38 +++++++ .../static/method-deco-returns-replacement.js | 33 ++++++ .../static/method-deco-returns-undefined.js | 37 +++++++ ...thod-generator-deco-returns-replacement.js | 33 ++++++ ...method-generator-deco-returns-undefined.js | 37 +++++++ .../public/instance/context-access-get.js | 34 ++++++ .../public/instance/context-kind-method.js | 31 ++++++ .../public/instance/context-name-public.js | 31 ++++++ .../public/instance/context-private-true.js | 31 ++++++ .../public/instance/context-static-false.js | 31 ++++++ ...ator-order-application-method-and-class.js | 39 +++++++ .../method-deco-returns-replacement.js | 34 ++++++ .../instance/method-deco-returns-undefined.js | 38 +++++++ ...thod-generator-deco-returns-replacement.js | 34 ++++++ ...method-generator-deco-returns-undefined.js | 38 +++++++ .../public/static/context-access-get.js | 33 ++++++ .../public/static/context-kind-method.js | 30 ++++++ .../public/static/context-name-public.js | 30 ++++++ .../public/static/context-private-true.js | 30 ++++++ .../public/static/context-static-true.js | 30 ++++++ ...ator-order-application-method-and-class.js | 38 +++++++ .../static/method-deco-returns-replacement.js | 33 ++++++ .../static/method-deco-returns-undefined.js | 37 +++++++ ...thod-generator-deco-returns-replacement.js | 33 ++++++ ...method-generator-deco-returns-undefined.js | 37 +++++++ .../instance/setter-deco-returns-invalid.js | 25 +++++ .../static/setter-deco-returns-invalid.js | 26 +++++ .../instance/setter-deco-returns-invalid.js | 26 +++++ .../static/setter-deco-returns-invalid.js | 26 +++++ .../private/instance/context-access-set.js | 39 +++++++ .../private/instance/context-kind-setter.js | 35 ++++++ .../private/instance/context-name-private.js | 35 ++++++ .../private/instance/context-private-false.js | 35 ++++++ .../private/instance/context-static-false.js | 35 ++++++ .../setter-deco-returns-replacement.js | 41 +++++++ .../instance/setter-deco-returns-undefined.js | 47 ++++++++ .../private/static/context-access-set.js | 39 +++++++ .../private/static/context-kind-setter.js | 35 ++++++ .../private/static/context-name-private.js | 35 ++++++ .../private/static/context-private-false.js | 35 ++++++ .../private/static/context-static-true.js | 35 ++++++ .../static/setter-deco-returns-replacement.js | 41 +++++++ .../static/setter-deco-returns-undefined.js | 47 ++++++++ .../public/instance/context-access-set.js | 40 +++++++ .../public/instance/context-kind-setter.js | 36 +++++++ .../public/instance/context-name-public.js | 36 +++++++ .../public/instance/context-private-true.js | 36 +++++++ .../public/instance/context-static-false.js | 36 +++++++ .../setter-deco-returns-replacement.js | 42 ++++++++ .../instance/setter-deco-returns-undefined.js | 48 +++++++++ .../public/static/context-access-set.js | 39 +++++++ .../public/static/context-kind-setter.js | 35 ++++++ .../public/static/context-name-public.js | 35 ++++++ .../public/static/context-private-true.js | 35 ++++++ .../public/static/context-static-true.js | 35 ++++++ .../static/setter-deco-returns-replacement.js | 41 +++++++ .../static/setter-deco-returns-undefined.js | 47 ++++++++ 557 files changed, 19833 insertions(+) create mode 100644 test/language/expressions/class/decorator/accessor/error/private/instance/accessor-deco-invalid-return-get.js create mode 100644 test/language/expressions/class/decorator/accessor/error/private/instance/accessor-deco-invalid-return-init.js create mode 100644 test/language/expressions/class/decorator/accessor/error/private/instance/accessor-deco-invalid-return-set.js create mode 100644 test/language/expressions/class/decorator/accessor/error/private/instance/accessor-deco-invalid-return.js create mode 100644 test/language/expressions/class/decorator/accessor/error/private/static/accessor-deco-invalid-return-get.js create mode 100644 test/language/expressions/class/decorator/accessor/error/private/static/accessor-deco-invalid-return-init.js create mode 100644 test/language/expressions/class/decorator/accessor/error/private/static/accessor-deco-invalid-return-set.js create mode 100644 test/language/expressions/class/decorator/accessor/error/private/static/accessor-deco-invalid-return.js create mode 100644 test/language/expressions/class/decorator/accessor/error/public/instance/accessor-deco-invalid-return-get.js create mode 100644 test/language/expressions/class/decorator/accessor/error/public/instance/accessor-deco-invalid-return-init.js create mode 100644 test/language/expressions/class/decorator/accessor/error/public/instance/accessor-deco-invalid-return-set.js create mode 100644 test/language/expressions/class/decorator/accessor/error/public/instance/accessor-deco-invalid-return.js create mode 100644 test/language/expressions/class/decorator/accessor/private/instance/accessor-deco-returns-get.js create mode 100644 test/language/expressions/class/decorator/accessor/private/instance/accessor-deco-returns-init.js create mode 100644 test/language/expressions/class/decorator/accessor/private/instance/accessor-deco-returns-set.js create mode 100644 test/language/expressions/class/decorator/accessor/private/instance/context-access-get.js create mode 100644 test/language/expressions/class/decorator/accessor/private/instance/context-access-set.js create mode 100644 test/language/expressions/class/decorator/accessor/private/instance/context-kind-accessor.js create mode 100644 test/language/expressions/class/decorator/accessor/private/instance/context-name-private.js create mode 100644 test/language/expressions/class/decorator/accessor/private/instance/context-private-false.js create mode 100644 test/language/expressions/class/decorator/accessor/private/instance/context-static-false.js create mode 100644 test/language/expressions/class/decorator/accessor/private/instance/field-and-accessor-init-this.js create mode 100644 test/language/expressions/class/decorator/accessor/private/static/accessor-deco-returns-get.js create mode 100644 test/language/expressions/class/decorator/accessor/private/static/accessor-deco-returns-init.js create mode 100644 test/language/expressions/class/decorator/accessor/private/static/accessor-deco-returns-set.js create mode 100644 test/language/expressions/class/decorator/accessor/private/static/context-access-get.js create mode 100644 test/language/expressions/class/decorator/accessor/private/static/context-access-set.js create mode 100644 test/language/expressions/class/decorator/accessor/private/static/context-kind-accessor.js create mode 100644 test/language/expressions/class/decorator/accessor/private/static/context-name-private.js create mode 100644 test/language/expressions/class/decorator/accessor/private/static/context-private-false.js create mode 100644 test/language/expressions/class/decorator/accessor/private/static/context-static-true.js create mode 100644 test/language/expressions/class/decorator/accessor/private/static/field-and-accessor-init-this.js create mode 100644 test/language/expressions/class/decorator/accessor/public/instance/accessor-deco-returns-get.js create mode 100644 test/language/expressions/class/decorator/accessor/public/instance/accessor-deco-returns-init.js create mode 100644 test/language/expressions/class/decorator/accessor/public/instance/accessor-deco-returns-set.js create mode 100644 test/language/expressions/class/decorator/accessor/public/instance/context-access-get.js create mode 100644 test/language/expressions/class/decorator/accessor/public/instance/context-access-set.js create mode 100644 test/language/expressions/class/decorator/accessor/public/instance/context-kind-accessor.js create mode 100644 test/language/expressions/class/decorator/accessor/public/instance/context-name-public.js create mode 100644 test/language/expressions/class/decorator/accessor/public/instance/context-private-true.js create mode 100644 test/language/expressions/class/decorator/accessor/public/instance/context-static-false.js create mode 100644 test/language/expressions/class/decorator/accessor/public/instance/field-and-accessor-init-this.js create mode 100644 test/language/expressions/class/decorator/accessor/public/static/accessor-deco-invalid-return-get.js create mode 100644 test/language/expressions/class/decorator/accessor/public/static/accessor-deco-invalid-return-init.js create mode 100644 test/language/expressions/class/decorator/accessor/public/static/accessor-deco-invalid-return-set.js create mode 100644 test/language/expressions/class/decorator/accessor/public/static/accessor-deco-invalid-return.js create mode 100644 test/language/expressions/class/decorator/accessor/public/static/accessor-deco-returns-get.js create mode 100644 test/language/expressions/class/decorator/accessor/public/static/accessor-deco-returns-init.js create mode 100644 test/language/expressions/class/decorator/accessor/public/static/accessor-deco-returns-set.js create mode 100644 test/language/expressions/class/decorator/accessor/public/static/context-access-get.js create mode 100644 test/language/expressions/class/decorator/accessor/public/static/context-access-set.js create mode 100644 test/language/expressions/class/decorator/accessor/public/static/context-kind-accessor.js create mode 100644 test/language/expressions/class/decorator/accessor/public/static/context-name-public.js create mode 100644 test/language/expressions/class/decorator/accessor/public/static/context-private-true.js create mode 100644 test/language/expressions/class/decorator/accessor/public/static/context-static-true.js create mode 100644 test/language/expressions/class/decorator/accessor/public/static/field-and-accessor-init-this.js create mode 100644 test/language/expressions/class/decorator/accessor/with-init/private/instance/accessor-with-init-deco-returns-get.js create mode 100644 test/language/expressions/class/decorator/accessor/with-init/private/instance/accessor-with-init-deco-returns-init.js create mode 100644 test/language/expressions/class/decorator/accessor/with-init/private/instance/accessor-with-init-deco-returns-set.js create mode 100644 test/language/expressions/class/decorator/accessor/with-init/private/instance/context-access-get.js create mode 100644 test/language/expressions/class/decorator/accessor/with-init/private/instance/context-access-set.js create mode 100644 test/language/expressions/class/decorator/accessor/with-init/private/instance/decorator-order-application-field-and-accessor.js create mode 100644 test/language/expressions/class/decorator/accessor/with-init/private/instance/field-and-accessor-init-this.js create mode 100644 test/language/expressions/class/decorator/accessor/with-init/private/static/accessor-with-init-deco-returns-get.js create mode 100644 test/language/expressions/class/decorator/accessor/with-init/private/static/accessor-with-init-deco-returns-init.js create mode 100644 test/language/expressions/class/decorator/accessor/with-init/private/static/accessor-with-init-deco-returns-set.js create mode 100644 test/language/expressions/class/decorator/accessor/with-init/private/static/context-access-get.js create mode 100644 test/language/expressions/class/decorator/accessor/with-init/private/static/context-access-set.js create mode 100644 test/language/expressions/class/decorator/accessor/with-init/private/static/decorator-order-application-field-and-accessor.js create mode 100644 test/language/expressions/class/decorator/accessor/with-init/private/static/field-and-accessor-init-this.js create mode 100644 test/language/expressions/class/decorator/accessor/with-init/public/instance/accessor-with-init-deco-returns-get.js create mode 100644 test/language/expressions/class/decorator/accessor/with-init/public/instance/accessor-with-init-deco-returns-init.js create mode 100644 test/language/expressions/class/decorator/accessor/with-init/public/instance/accessor-with-init-deco-returns-set.js create mode 100644 test/language/expressions/class/decorator/accessor/with-init/public/instance/context-access-get.js create mode 100644 test/language/expressions/class/decorator/accessor/with-init/public/instance/context-access-set.js create mode 100644 test/language/expressions/class/decorator/accessor/with-init/public/instance/decorator-order-application-field-and-accessor.js create mode 100644 test/language/expressions/class/decorator/accessor/with-init/public/instance/field-and-accessor-init-this.js create mode 100644 test/language/expressions/class/decorator/accessor/with-init/public/static/accessor-with-init-deco-returns-get.js create mode 100644 test/language/expressions/class/decorator/accessor/with-init/public/static/accessor-with-init-deco-returns-init.js create mode 100644 test/language/expressions/class/decorator/accessor/with-init/public/static/accessor-with-init-deco-returns-set.js create mode 100644 test/language/expressions/class/decorator/accessor/with-init/public/static/context-access-get.js create mode 100644 test/language/expressions/class/decorator/accessor/with-init/public/static/context-access-set.js create mode 100644 test/language/expressions/class/decorator/accessor/with-init/public/static/decorator-order-application-field-and-accessor.js create mode 100644 test/language/expressions/class/decorator/accessor/with-init/public/static/field-and-accessor-init-this.js create mode 100644 test/language/expressions/class/decorator/class/class-deco-returns-class.js create mode 100644 test/language/expressions/class/decorator/class/class-deco-returns-function.js create mode 100644 test/language/expressions/class/decorator/class/class-deco-returns-proxy.js create mode 100644 test/language/expressions/class/decorator/class/class-deco-returns-subclass.js create mode 100644 test/language/expressions/class/decorator/class/context-kind-class.js create mode 100644 test/language/expressions/class/decorator/class/context-name-class.js create mode 100644 test/language/expressions/class/decorator/class/decorator-order-application-method-and-class.js create mode 100644 test/language/expressions/class/decorator/class/decorator-order-phases-1-pre-definition.js create mode 100644 test/language/expressions/class/decorator/class/decorator-order-phases-2-application.js create mode 100644 test/language/expressions/class/decorator/class/decorator-order-phases-3-init-static.js create mode 100644 test/language/expressions/class/decorator/class/decorator-order-phases.js create mode 100644 test/language/expressions/class/decorator/class/error/class-deco-invalid-return-arrow.js create mode 100644 test/language/expressions/class/decorator/class/error/class-deco-invalid-return-primitive.js create mode 100644 test/language/expressions/class/decorator/class/with-super-class/decorator-order-phases-4-init-instance.js create mode 100644 test/language/expressions/class/decorator/field/error/private/instance/field-deco-invalid-return.js create mode 100644 test/language/expressions/class/decorator/field/error/private/static/field-deco-invalid-return.js create mode 100644 test/language/expressions/class/decorator/field/error/public/instance/field-deco-invalid-return.js create mode 100644 test/language/expressions/class/decorator/field/private/instance/context-access-set.js create mode 100644 test/language/expressions/class/decorator/field/private/instance/context-kind-field.js create mode 100644 test/language/expressions/class/decorator/field/private/instance/context-name-private.js create mode 100644 test/language/expressions/class/decorator/field/private/instance/context-private-false.js create mode 100644 test/language/expressions/class/decorator/field/private/instance/context-static-false.js create mode 100644 test/language/expressions/class/decorator/field/private/instance/field-and-accessor-init-this.js create mode 100644 test/language/expressions/class/decorator/field/private/instance/field-deco-returns-initializer.js create mode 100644 test/language/expressions/class/decorator/field/private/instance/field-deco-returns-undefined.js create mode 100644 test/language/expressions/class/decorator/field/private/static/context-access-set.js create mode 100644 test/language/expressions/class/decorator/field/private/static/context-kind-field.js create mode 100644 test/language/expressions/class/decorator/field/private/static/context-name-private.js create mode 100644 test/language/expressions/class/decorator/field/private/static/context-private-false.js create mode 100644 test/language/expressions/class/decorator/field/private/static/context-static-true.js create mode 100644 test/language/expressions/class/decorator/field/private/static/field-and-accessor-init-this.js create mode 100644 test/language/expressions/class/decorator/field/private/static/field-deco-returns-initializer.js create mode 100644 test/language/expressions/class/decorator/field/private/static/field-deco-returns-undefined.js create mode 100644 test/language/expressions/class/decorator/field/public/instance/context-access-set.js create mode 100644 test/language/expressions/class/decorator/field/public/instance/context-kind-field.js create mode 100644 test/language/expressions/class/decorator/field/public/instance/context-name-public.js create mode 100644 test/language/expressions/class/decorator/field/public/instance/context-private-true.js create mode 100644 test/language/expressions/class/decorator/field/public/instance/context-static-false.js create mode 100644 test/language/expressions/class/decorator/field/public/instance/field-and-accessor-init-this.js create mode 100644 test/language/expressions/class/decorator/field/public/instance/field-deco-returns-initializer.js create mode 100644 test/language/expressions/class/decorator/field/public/instance/field-deco-returns-undefined.js create mode 100644 test/language/expressions/class/decorator/field/public/static/context-access-set.js create mode 100644 test/language/expressions/class/decorator/field/public/static/context-kind-field.js create mode 100644 test/language/expressions/class/decorator/field/public/static/context-name-public.js create mode 100644 test/language/expressions/class/decorator/field/public/static/context-private-true.js create mode 100644 test/language/expressions/class/decorator/field/public/static/context-static-true.js create mode 100644 test/language/expressions/class/decorator/field/public/static/field-and-accessor-init-this.js create mode 100644 test/language/expressions/class/decorator/field/public/static/field-deco-invalid-return.js create mode 100644 test/language/expressions/class/decorator/field/public/static/field-deco-returns-initializer.js create mode 100644 test/language/expressions/class/decorator/field/public/static/field-deco-returns-undefined.js create mode 100644 test/language/expressions/class/decorator/field/with-init/private/instance/context-access-get.js create mode 100644 test/language/expressions/class/decorator/field/with-init/private/instance/context-access-set.js create mode 100644 test/language/expressions/class/decorator/field/with-init/private/instance/decorator-order-application-field-and-accessor.js create mode 100644 test/language/expressions/class/decorator/field/with-init/private/instance/field-and-accessor-init-this.js create mode 100644 test/language/expressions/class/decorator/field/with-init/private/instance/field-receives-undefined.js create mode 100644 test/language/expressions/class/decorator/field/with-init/private/instance/field-with-init-deco-returns-initializer.js create mode 100644 test/language/expressions/class/decorator/field/with-init/private/instance/field-with-init-deco-returns-undefined.js create mode 100644 test/language/expressions/class/decorator/field/with-init/private/static/context-access-get.js create mode 100644 test/language/expressions/class/decorator/field/with-init/private/static/context-access-set.js create mode 100644 test/language/expressions/class/decorator/field/with-init/private/static/decorator-order-application-field-and-accessor.js create mode 100644 test/language/expressions/class/decorator/field/with-init/private/static/field-and-accessor-init-this.js create mode 100644 test/language/expressions/class/decorator/field/with-init/private/static/field-receives-undefined.js create mode 100644 test/language/expressions/class/decorator/field/with-init/private/static/field-with-init-deco-returns-initializer.js create mode 100644 test/language/expressions/class/decorator/field/with-init/private/static/field-with-init-deco-returns-undefined.js create mode 100644 test/language/expressions/class/decorator/field/with-init/public/instance/context-access-get.js create mode 100644 test/language/expressions/class/decorator/field/with-init/public/instance/context-access-set.js create mode 100644 test/language/expressions/class/decorator/field/with-init/public/instance/decorator-order-application-field-and-accessor.js create mode 100644 test/language/expressions/class/decorator/field/with-init/public/instance/field-and-accessor-init-this.js create mode 100644 test/language/expressions/class/decorator/field/with-init/public/instance/field-receives-undefined.js create mode 100644 test/language/expressions/class/decorator/field/with-init/public/instance/field-with-init-deco-returns-initializer.js create mode 100644 test/language/expressions/class/decorator/field/with-init/public/instance/field-with-init-deco-returns-undefined.js create mode 100644 test/language/expressions/class/decorator/field/with-init/public/static/context-access-get.js create mode 100644 test/language/expressions/class/decorator/field/with-init/public/static/context-access-set.js create mode 100644 test/language/expressions/class/decorator/field/with-init/public/static/decorator-order-application-field-and-accessor.js create mode 100644 test/language/expressions/class/decorator/field/with-init/public/static/field-and-accessor-init-this.js create mode 100644 test/language/expressions/class/decorator/field/with-init/public/static/field-receives-undefined.js create mode 100644 test/language/expressions/class/decorator/field/with-init/public/static/field-with-init-deco-returns-initializer.js create mode 100644 test/language/expressions/class/decorator/field/with-init/public/static/field-with-init-deco-returns-undefined.js create mode 100644 test/language/expressions/class/decorator/getter/error/private/instance/getter-deco-returns-invalid.js create mode 100644 test/language/expressions/class/decorator/getter/error/private/static/context-kind-getter.js create mode 100644 test/language/expressions/class/decorator/getter/error/private/static/context-name-private.js create mode 100644 test/language/expressions/class/decorator/getter/error/private/static/context-private-false.js create mode 100644 test/language/expressions/class/decorator/getter/error/private/static/context-static-true.js create mode 100644 test/language/expressions/class/decorator/getter/error/private/static/getter-deco-returns-invalid.js create mode 100644 test/language/expressions/class/decorator/getter/error/private/static/getter-deco-returns-replacement.js create mode 100644 test/language/expressions/class/decorator/getter/error/private/static/getter-deco-returns-undefined.js create mode 100644 test/language/expressions/class/decorator/getter/error/public/instance/getter-deco-returns-invalid.js create mode 100644 test/language/expressions/class/decorator/getter/error/public/static/getter-deco-returns-invalid.js create mode 100644 test/language/expressions/class/decorator/getter/private/instance/context-kind-getter.js create mode 100644 test/language/expressions/class/decorator/getter/private/instance/context-name-private.js create mode 100644 test/language/expressions/class/decorator/getter/private/instance/context-private-false.js create mode 100644 test/language/expressions/class/decorator/getter/private/instance/context-static-false.js create mode 100644 test/language/expressions/class/decorator/getter/private/instance/getter-deco-returns-replacement.js create mode 100644 test/language/expressions/class/decorator/getter/private/instance/getter-deco-returns-undefined.js create mode 100644 test/language/expressions/class/decorator/getter/public/instance/context-kind-getter.js create mode 100644 test/language/expressions/class/decorator/getter/public/instance/context-name-public.js create mode 100644 test/language/expressions/class/decorator/getter/public/instance/context-private-true.js create mode 100644 test/language/expressions/class/decorator/getter/public/instance/context-static-false.js create mode 100644 test/language/expressions/class/decorator/getter/public/instance/getter-deco-returns-replacement.js create mode 100644 test/language/expressions/class/decorator/getter/public/instance/getter-deco-returns-undefined.js create mode 100644 test/language/expressions/class/decorator/getter/public/static/context-kind-getter.js create mode 100644 test/language/expressions/class/decorator/getter/public/static/context-name-public.js create mode 100644 test/language/expressions/class/decorator/getter/public/static/context-private-true.js create mode 100644 test/language/expressions/class/decorator/getter/public/static/context-static-true.js create mode 100644 test/language/expressions/class/decorator/getter/public/static/getter-deco-returns-replacement.js create mode 100644 test/language/expressions/class/decorator/getter/public/static/getter-deco-returns-undefined.js create mode 100644 test/language/expressions/class/decorator/method/async/private/instance/context-kind-method.js create mode 100644 test/language/expressions/class/decorator/method/async/private/instance/method-async-deco-returns-replacement.js create mode 100644 test/language/expressions/class/decorator/method/async/private/instance/method-async-deco-returns-undefined.js create mode 100644 test/language/expressions/class/decorator/method/async/private/static/context-kind-method.js create mode 100644 test/language/expressions/class/decorator/method/async/private/static/method-async-deco-returns-replacement.js create mode 100644 test/language/expressions/class/decorator/method/async/private/static/method-async-deco-returns-undefined.js create mode 100644 test/language/expressions/class/decorator/method/async/public/instance/context-kind-method.js create mode 100644 test/language/expressions/class/decorator/method/async/public/instance/method-async-deco-returns-replacement.js create mode 100644 test/language/expressions/class/decorator/method/async/public/instance/method-async-deco-returns-undefined.js create mode 100644 test/language/expressions/class/decorator/method/async/public/static/context-kind-method.js create mode 100644 test/language/expressions/class/decorator/method/async/public/static/method-async-deco-returns-replacement.js create mode 100644 test/language/expressions/class/decorator/method/async/public/static/method-async-deco-returns-undefined.js create mode 100644 test/language/expressions/class/decorator/method/error/private/instance/method-deco-returns-invalid.js create mode 100644 test/language/expressions/class/decorator/method/error/private/static/method-deco-returns-invalid.js create mode 100644 test/language/expressions/class/decorator/method/error/public/instance/method-deco-returns-invalid.js create mode 100644 test/language/expressions/class/decorator/method/error/public/static/method-deco-returns-invalid.js create mode 100644 test/language/expressions/class/decorator/method/private/instance/context-access-get.js create mode 100644 test/language/expressions/class/decorator/method/private/instance/context-kind-method.js create mode 100644 test/language/expressions/class/decorator/method/private/instance/context-name-private.js create mode 100644 test/language/expressions/class/decorator/method/private/instance/context-private-false.js create mode 100644 test/language/expressions/class/decorator/method/private/instance/context-static-false.js create mode 100644 test/language/expressions/class/decorator/method/private/instance/decorator-order-application-method-and-class.js create mode 100644 test/language/expressions/class/decorator/method/private/instance/method-deco-returns-replacement.js create mode 100644 test/language/expressions/class/decorator/method/private/instance/method-deco-returns-undefined.js create mode 100644 test/language/expressions/class/decorator/method/private/instance/method-generator-deco-returns-replacement.js create mode 100644 test/language/expressions/class/decorator/method/private/instance/method-generator-deco-returns-undefined.js create mode 100644 test/language/expressions/class/decorator/method/private/static/context-access-get.js create mode 100644 test/language/expressions/class/decorator/method/private/static/context-kind-method.js create mode 100644 test/language/expressions/class/decorator/method/private/static/context-name-private.js create mode 100644 test/language/expressions/class/decorator/method/private/static/context-private-false.js create mode 100644 test/language/expressions/class/decorator/method/private/static/context-static-true.js create mode 100644 test/language/expressions/class/decorator/method/private/static/decorator-order-application-method-and-class.js create mode 100644 test/language/expressions/class/decorator/method/private/static/method-deco-returns-replacement.js create mode 100644 test/language/expressions/class/decorator/method/private/static/method-deco-returns-undefined.js create mode 100644 test/language/expressions/class/decorator/method/private/static/method-generator-deco-returns-replacement.js create mode 100644 test/language/expressions/class/decorator/method/private/static/method-generator-deco-returns-undefined.js create mode 100644 test/language/expressions/class/decorator/method/public/instance/context-access-get.js create mode 100644 test/language/expressions/class/decorator/method/public/instance/context-kind-method.js create mode 100644 test/language/expressions/class/decorator/method/public/instance/context-name-public.js create mode 100644 test/language/expressions/class/decorator/method/public/instance/context-private-true.js create mode 100644 test/language/expressions/class/decorator/method/public/instance/context-static-false.js create mode 100644 test/language/expressions/class/decorator/method/public/instance/decorator-order-application-method-and-class.js create mode 100644 test/language/expressions/class/decorator/method/public/instance/method-deco-returns-replacement.js create mode 100644 test/language/expressions/class/decorator/method/public/instance/method-deco-returns-undefined.js create mode 100644 test/language/expressions/class/decorator/method/public/instance/method-generator-deco-returns-replacement.js create mode 100644 test/language/expressions/class/decorator/method/public/instance/method-generator-deco-returns-undefined.js create mode 100644 test/language/expressions/class/decorator/method/public/static/context-access-get.js create mode 100644 test/language/expressions/class/decorator/method/public/static/context-kind-method.js create mode 100644 test/language/expressions/class/decorator/method/public/static/context-name-public.js create mode 100644 test/language/expressions/class/decorator/method/public/static/context-private-true.js create mode 100644 test/language/expressions/class/decorator/method/public/static/context-static-true.js create mode 100644 test/language/expressions/class/decorator/method/public/static/decorator-order-application-method-and-class.js create mode 100644 test/language/expressions/class/decorator/method/public/static/method-deco-returns-replacement.js create mode 100644 test/language/expressions/class/decorator/method/public/static/method-deco-returns-undefined.js create mode 100644 test/language/expressions/class/decorator/method/public/static/method-generator-deco-returns-replacement.js create mode 100644 test/language/expressions/class/decorator/method/public/static/method-generator-deco-returns-undefined.js create mode 100644 test/language/expressions/class/decorator/setter/error/private/instance/setter-deco-returns-invalid.js create mode 100644 test/language/expressions/class/decorator/setter/error/private/static/setter-deco-returns-invalid.js create mode 100644 test/language/expressions/class/decorator/setter/error/public/instance/setter-deco-returns-invalid.js create mode 100644 test/language/expressions/class/decorator/setter/error/public/static/setter-deco-returns-invalid.js create mode 100644 test/language/expressions/class/decorator/setter/private/instance/context-access-set.js create mode 100644 test/language/expressions/class/decorator/setter/private/instance/context-kind-setter.js create mode 100644 test/language/expressions/class/decorator/setter/private/instance/context-name-private.js create mode 100644 test/language/expressions/class/decorator/setter/private/instance/context-private-false.js create mode 100644 test/language/expressions/class/decorator/setter/private/instance/context-static-false.js create mode 100644 test/language/expressions/class/decorator/setter/private/instance/setter-deco-returns-replacement.js create mode 100644 test/language/expressions/class/decorator/setter/private/instance/setter-deco-returns-undefined.js create mode 100644 test/language/expressions/class/decorator/setter/private/static/context-access-set.js create mode 100644 test/language/expressions/class/decorator/setter/private/static/context-kind-setter.js create mode 100644 test/language/expressions/class/decorator/setter/private/static/context-name-private.js create mode 100644 test/language/expressions/class/decorator/setter/private/static/context-private-false.js create mode 100644 test/language/expressions/class/decorator/setter/private/static/context-static-true.js create mode 100644 test/language/expressions/class/decorator/setter/private/static/setter-deco-returns-replacement.js create mode 100644 test/language/expressions/class/decorator/setter/private/static/setter-deco-returns-undefined.js create mode 100644 test/language/expressions/class/decorator/setter/public/instance/context-access-set.js create mode 100644 test/language/expressions/class/decorator/setter/public/instance/context-kind-setter.js create mode 100644 test/language/expressions/class/decorator/setter/public/instance/context-name-public.js create mode 100644 test/language/expressions/class/decorator/setter/public/instance/context-private-true.js create mode 100644 test/language/expressions/class/decorator/setter/public/instance/context-static-false.js create mode 100644 test/language/expressions/class/decorator/setter/public/instance/setter-deco-returns-replacement.js create mode 100644 test/language/expressions/class/decorator/setter/public/instance/setter-deco-returns-undefined.js create mode 100644 test/language/expressions/class/decorator/setter/public/static/context-access-set.js create mode 100644 test/language/expressions/class/decorator/setter/public/static/context-kind-setter.js create mode 100644 test/language/expressions/class/decorator/setter/public/static/context-name-public.js create mode 100644 test/language/expressions/class/decorator/setter/public/static/context-private-true.js create mode 100644 test/language/expressions/class/decorator/setter/public/static/context-static-true.js create mode 100644 test/language/expressions/class/decorator/setter/public/static/setter-deco-returns-replacement.js create mode 100644 test/language/expressions/class/decorator/setter/public/static/setter-deco-returns-undefined.js create mode 100644 test/language/statements/class/decorator/accessor/error/private/instance/accessor-deco-invalid-return-get.js create mode 100644 test/language/statements/class/decorator/accessor/error/private/instance/accessor-deco-invalid-return-init.js create mode 100644 test/language/statements/class/decorator/accessor/error/private/instance/accessor-deco-invalid-return-set.js create mode 100644 test/language/statements/class/decorator/accessor/error/private/instance/accessor-deco-invalid-return.js create mode 100644 test/language/statements/class/decorator/accessor/error/private/static/accessor-deco-invalid-return-get.js create mode 100644 test/language/statements/class/decorator/accessor/error/private/static/accessor-deco-invalid-return-init.js create mode 100644 test/language/statements/class/decorator/accessor/error/private/static/accessor-deco-invalid-return-set.js create mode 100644 test/language/statements/class/decorator/accessor/error/private/static/accessor-deco-invalid-return.js create mode 100644 test/language/statements/class/decorator/accessor/error/public/instance/accessor-deco-invalid-return-get.js create mode 100644 test/language/statements/class/decorator/accessor/error/public/instance/accessor-deco-invalid-return-init.js create mode 100644 test/language/statements/class/decorator/accessor/error/public/instance/accessor-deco-invalid-return-set.js create mode 100644 test/language/statements/class/decorator/accessor/error/public/instance/accessor-deco-invalid-return.js create mode 100644 test/language/statements/class/decorator/accessor/private/instance/accessor-deco-returns-get.js create mode 100644 test/language/statements/class/decorator/accessor/private/instance/accessor-deco-returns-init.js create mode 100644 test/language/statements/class/decorator/accessor/private/instance/accessor-deco-returns-set.js create mode 100644 test/language/statements/class/decorator/accessor/private/instance/context-access-get.js create mode 100644 test/language/statements/class/decorator/accessor/private/instance/context-access-set.js create mode 100644 test/language/statements/class/decorator/accessor/private/instance/context-kind-accessor.js create mode 100644 test/language/statements/class/decorator/accessor/private/instance/context-name-private.js create mode 100644 test/language/statements/class/decorator/accessor/private/instance/context-private-false.js create mode 100644 test/language/statements/class/decorator/accessor/private/instance/context-static-false.js create mode 100644 test/language/statements/class/decorator/accessor/private/instance/field-and-accessor-init-this.js create mode 100644 test/language/statements/class/decorator/accessor/private/static/accessor-deco-returns-get.js create mode 100644 test/language/statements/class/decorator/accessor/private/static/accessor-deco-returns-init.js create mode 100644 test/language/statements/class/decorator/accessor/private/static/accessor-deco-returns-set.js create mode 100644 test/language/statements/class/decorator/accessor/private/static/context-access-get.js create mode 100644 test/language/statements/class/decorator/accessor/private/static/context-access-set.js create mode 100644 test/language/statements/class/decorator/accessor/private/static/context-kind-accessor.js create mode 100644 test/language/statements/class/decorator/accessor/private/static/context-name-private.js create mode 100644 test/language/statements/class/decorator/accessor/private/static/context-private-false.js create mode 100644 test/language/statements/class/decorator/accessor/private/static/context-static-true.js create mode 100644 test/language/statements/class/decorator/accessor/private/static/field-and-accessor-init-this.js create mode 100644 test/language/statements/class/decorator/accessor/public/instance/accessor-deco-returns-get.js create mode 100644 test/language/statements/class/decorator/accessor/public/instance/accessor-deco-returns-init.js create mode 100644 test/language/statements/class/decorator/accessor/public/instance/accessor-deco-returns-set.js create mode 100644 test/language/statements/class/decorator/accessor/public/instance/context-access-get.js create mode 100644 test/language/statements/class/decorator/accessor/public/instance/context-access-set.js create mode 100644 test/language/statements/class/decorator/accessor/public/instance/context-kind-accessor.js create mode 100644 test/language/statements/class/decorator/accessor/public/instance/context-name-public.js create mode 100644 test/language/statements/class/decorator/accessor/public/instance/context-private-true.js create mode 100644 test/language/statements/class/decorator/accessor/public/instance/context-static-false.js create mode 100644 test/language/statements/class/decorator/accessor/public/instance/field-and-accessor-init-this.js create mode 100644 test/language/statements/class/decorator/accessor/public/static/accessor-deco-invalid-return-get.js create mode 100644 test/language/statements/class/decorator/accessor/public/static/accessor-deco-invalid-return-init.js create mode 100644 test/language/statements/class/decorator/accessor/public/static/accessor-deco-invalid-return-set.js create mode 100644 test/language/statements/class/decorator/accessor/public/static/accessor-deco-invalid-return.js create mode 100644 test/language/statements/class/decorator/accessor/public/static/accessor-deco-returns-get.js create mode 100644 test/language/statements/class/decorator/accessor/public/static/accessor-deco-returns-init.js create mode 100644 test/language/statements/class/decorator/accessor/public/static/accessor-deco-returns-set.js create mode 100644 test/language/statements/class/decorator/accessor/public/static/context-access-get.js create mode 100644 test/language/statements/class/decorator/accessor/public/static/context-access-set.js create mode 100644 test/language/statements/class/decorator/accessor/public/static/context-kind-accessor.js create mode 100644 test/language/statements/class/decorator/accessor/public/static/context-name-public.js create mode 100644 test/language/statements/class/decorator/accessor/public/static/context-private-true.js create mode 100644 test/language/statements/class/decorator/accessor/public/static/context-static-true.js create mode 100644 test/language/statements/class/decorator/accessor/public/static/field-and-accessor-init-this.js create mode 100644 test/language/statements/class/decorator/accessor/with-init/private/instance/accessor-with-init-deco-returns-get.js create mode 100644 test/language/statements/class/decorator/accessor/with-init/private/instance/accessor-with-init-deco-returns-init.js create mode 100644 test/language/statements/class/decorator/accessor/with-init/private/instance/accessor-with-init-deco-returns-set.js create mode 100644 test/language/statements/class/decorator/accessor/with-init/private/instance/context-access-get.js create mode 100644 test/language/statements/class/decorator/accessor/with-init/private/instance/context-access-set.js create mode 100644 test/language/statements/class/decorator/accessor/with-init/private/instance/decorator-order-application-field-and-accessor.js create mode 100644 test/language/statements/class/decorator/accessor/with-init/private/instance/field-and-accessor-init-this.js create mode 100644 test/language/statements/class/decorator/accessor/with-init/private/static/accessor-with-init-deco-returns-get.js create mode 100644 test/language/statements/class/decorator/accessor/with-init/private/static/accessor-with-init-deco-returns-init.js create mode 100644 test/language/statements/class/decorator/accessor/with-init/private/static/accessor-with-init-deco-returns-set.js create mode 100644 test/language/statements/class/decorator/accessor/with-init/private/static/context-access-get.js create mode 100644 test/language/statements/class/decorator/accessor/with-init/private/static/context-access-set.js create mode 100644 test/language/statements/class/decorator/accessor/with-init/private/static/decorator-order-application-field-and-accessor.js create mode 100644 test/language/statements/class/decorator/accessor/with-init/private/static/field-and-accessor-init-this.js create mode 100644 test/language/statements/class/decorator/accessor/with-init/public/instance/accessor-with-init-deco-returns-get.js create mode 100644 test/language/statements/class/decorator/accessor/with-init/public/instance/accessor-with-init-deco-returns-init.js create mode 100644 test/language/statements/class/decorator/accessor/with-init/public/instance/accessor-with-init-deco-returns-set.js create mode 100644 test/language/statements/class/decorator/accessor/with-init/public/instance/context-access-get.js create mode 100644 test/language/statements/class/decorator/accessor/with-init/public/instance/context-access-set.js create mode 100644 test/language/statements/class/decorator/accessor/with-init/public/instance/decorator-order-application-field-and-accessor.js create mode 100644 test/language/statements/class/decorator/accessor/with-init/public/instance/field-and-accessor-init-this.js create mode 100644 test/language/statements/class/decorator/accessor/with-init/public/static/accessor-with-init-deco-returns-get.js create mode 100644 test/language/statements/class/decorator/accessor/with-init/public/static/accessor-with-init-deco-returns-init.js create mode 100644 test/language/statements/class/decorator/accessor/with-init/public/static/accessor-with-init-deco-returns-set.js create mode 100644 test/language/statements/class/decorator/accessor/with-init/public/static/context-access-get.js create mode 100644 test/language/statements/class/decorator/accessor/with-init/public/static/context-access-set.js create mode 100644 test/language/statements/class/decorator/accessor/with-init/public/static/decorator-order-application-field-and-accessor.js create mode 100644 test/language/statements/class/decorator/accessor/with-init/public/static/field-and-accessor-init-this.js create mode 100644 test/language/statements/class/decorator/class/class-deco-rebinds-identifier.js create mode 100644 test/language/statements/class/decorator/class/class-deco-returns-class.js create mode 100644 test/language/statements/class/decorator/class/class-deco-returns-function.js create mode 100644 test/language/statements/class/decorator/class/class-deco-returns-proxy.js create mode 100644 test/language/statements/class/decorator/class/class-deco-returns-subclass.js create mode 100644 test/language/statements/class/decorator/class/context-kind-class.js create mode 100644 test/language/statements/class/decorator/class/context-name-class.js create mode 100644 test/language/statements/class/decorator/class/decorator-order-application-method-and-class.js create mode 100644 test/language/statements/class/decorator/class/decorator-order-phases-1-pre-definition.js create mode 100644 test/language/statements/class/decorator/class/decorator-order-phases-2-application.js create mode 100644 test/language/statements/class/decorator/class/decorator-order-phases-3-init-static.js create mode 100644 test/language/statements/class/decorator/class/decorator-order-phases.js create mode 100644 test/language/statements/class/decorator/class/error/class-deco-invalid-return-arrow.js create mode 100644 test/language/statements/class/decorator/class/error/class-deco-invalid-return-primitive.js create mode 100644 test/language/statements/class/decorator/class/with-super-class/decorator-order-phases-4-init-instance.js create mode 100644 test/language/statements/class/decorator/field/error/private/instance/field-deco-invalid-return.js create mode 100644 test/language/statements/class/decorator/field/error/private/static/field-deco-invalid-return.js create mode 100644 test/language/statements/class/decorator/field/error/public/instance/field-deco-invalid-return.js create mode 100644 test/language/statements/class/decorator/field/private/instance/context-access-set.js create mode 100644 test/language/statements/class/decorator/field/private/instance/context-kind-field.js create mode 100644 test/language/statements/class/decorator/field/private/instance/context-name-private.js create mode 100644 test/language/statements/class/decorator/field/private/instance/context-private-false.js create mode 100644 test/language/statements/class/decorator/field/private/instance/context-static-false.js create mode 100644 test/language/statements/class/decorator/field/private/instance/field-and-accessor-init-this.js create mode 100644 test/language/statements/class/decorator/field/private/instance/field-deco-returns-initializer.js create mode 100644 test/language/statements/class/decorator/field/private/instance/field-deco-returns-undefined.js create mode 100644 test/language/statements/class/decorator/field/private/static/context-access-set.js create mode 100644 test/language/statements/class/decorator/field/private/static/context-kind-field.js create mode 100644 test/language/statements/class/decorator/field/private/static/context-name-private.js create mode 100644 test/language/statements/class/decorator/field/private/static/context-private-false.js create mode 100644 test/language/statements/class/decorator/field/private/static/context-static-true.js create mode 100644 test/language/statements/class/decorator/field/private/static/field-and-accessor-init-this.js create mode 100644 test/language/statements/class/decorator/field/private/static/field-deco-returns-initializer.js create mode 100644 test/language/statements/class/decorator/field/private/static/field-deco-returns-undefined.js create mode 100644 test/language/statements/class/decorator/field/public/instance/context-access-set.js create mode 100644 test/language/statements/class/decorator/field/public/instance/context-kind-field.js create mode 100644 test/language/statements/class/decorator/field/public/instance/context-name-public.js create mode 100644 test/language/statements/class/decorator/field/public/instance/context-private-true.js create mode 100644 test/language/statements/class/decorator/field/public/instance/context-static-false.js create mode 100644 test/language/statements/class/decorator/field/public/instance/field-and-accessor-init-this.js create mode 100644 test/language/statements/class/decorator/field/public/instance/field-deco-returns-initializer.js create mode 100644 test/language/statements/class/decorator/field/public/instance/field-deco-returns-undefined.js create mode 100644 test/language/statements/class/decorator/field/public/static/context-access-set.js create mode 100644 test/language/statements/class/decorator/field/public/static/context-kind-field.js create mode 100644 test/language/statements/class/decorator/field/public/static/context-name-public.js create mode 100644 test/language/statements/class/decorator/field/public/static/context-private-true.js create mode 100644 test/language/statements/class/decorator/field/public/static/context-static-true.js create mode 100644 test/language/statements/class/decorator/field/public/static/field-and-accessor-init-this.js create mode 100644 test/language/statements/class/decorator/field/public/static/field-deco-invalid-return.js create mode 100644 test/language/statements/class/decorator/field/public/static/field-deco-returns-initializer.js create mode 100644 test/language/statements/class/decorator/field/public/static/field-deco-returns-undefined.js create mode 100644 test/language/statements/class/decorator/field/with-init/private/instance/context-access-get.js create mode 100644 test/language/statements/class/decorator/field/with-init/private/instance/context-access-set.js create mode 100644 test/language/statements/class/decorator/field/with-init/private/instance/decorator-order-application-field-and-accessor.js create mode 100644 test/language/statements/class/decorator/field/with-init/private/instance/field-and-accessor-init-this.js create mode 100644 test/language/statements/class/decorator/field/with-init/private/instance/field-receives-undefined.js create mode 100644 test/language/statements/class/decorator/field/with-init/private/instance/field-with-init-deco-returns-initializer.js create mode 100644 test/language/statements/class/decorator/field/with-init/private/instance/field-with-init-deco-returns-undefined.js create mode 100644 test/language/statements/class/decorator/field/with-init/private/static/context-access-get.js create mode 100644 test/language/statements/class/decorator/field/with-init/private/static/context-access-set.js create mode 100644 test/language/statements/class/decorator/field/with-init/private/static/decorator-order-application-field-and-accessor.js create mode 100644 test/language/statements/class/decorator/field/with-init/private/static/field-and-accessor-init-this.js create mode 100644 test/language/statements/class/decorator/field/with-init/private/static/field-receives-undefined.js create mode 100644 test/language/statements/class/decorator/field/with-init/private/static/field-with-init-deco-returns-initializer.js create mode 100644 test/language/statements/class/decorator/field/with-init/private/static/field-with-init-deco-returns-undefined.js create mode 100644 test/language/statements/class/decorator/field/with-init/public/instance/context-access-get.js create mode 100644 test/language/statements/class/decorator/field/with-init/public/instance/context-access-set.js create mode 100644 test/language/statements/class/decorator/field/with-init/public/instance/decorator-order-application-field-and-accessor.js create mode 100644 test/language/statements/class/decorator/field/with-init/public/instance/field-and-accessor-init-this.js create mode 100644 test/language/statements/class/decorator/field/with-init/public/instance/field-receives-undefined.js create mode 100644 test/language/statements/class/decorator/field/with-init/public/instance/field-with-init-deco-returns-initializer.js create mode 100644 test/language/statements/class/decorator/field/with-init/public/instance/field-with-init-deco-returns-undefined.js create mode 100644 test/language/statements/class/decorator/field/with-init/public/static/context-access-get.js create mode 100644 test/language/statements/class/decorator/field/with-init/public/static/context-access-set.js create mode 100644 test/language/statements/class/decorator/field/with-init/public/static/decorator-order-application-field-and-accessor.js create mode 100644 test/language/statements/class/decorator/field/with-init/public/static/field-and-accessor-init-this.js create mode 100644 test/language/statements/class/decorator/field/with-init/public/static/field-receives-undefined.js create mode 100644 test/language/statements/class/decorator/field/with-init/public/static/field-with-init-deco-returns-initializer.js create mode 100644 test/language/statements/class/decorator/field/with-init/public/static/field-with-init-deco-returns-undefined.js create mode 100644 test/language/statements/class/decorator/getter/error/private/instance/getter-deco-returns-invalid.js create mode 100644 test/language/statements/class/decorator/getter/error/private/static/context-kind-getter.js create mode 100644 test/language/statements/class/decorator/getter/error/private/static/context-name-private.js create mode 100644 test/language/statements/class/decorator/getter/error/private/static/context-private-false.js create mode 100644 test/language/statements/class/decorator/getter/error/private/static/context-static-true.js create mode 100644 test/language/statements/class/decorator/getter/error/private/static/getter-deco-returns-invalid.js create mode 100644 test/language/statements/class/decorator/getter/error/private/static/getter-deco-returns-replacement.js create mode 100644 test/language/statements/class/decorator/getter/error/private/static/getter-deco-returns-undefined.js create mode 100644 test/language/statements/class/decorator/getter/error/public/instance/getter-deco-returns-invalid.js create mode 100644 test/language/statements/class/decorator/getter/error/public/static/getter-deco-returns-invalid.js create mode 100644 test/language/statements/class/decorator/getter/private/instance/context-kind-getter.js create mode 100644 test/language/statements/class/decorator/getter/private/instance/context-name-private.js create mode 100644 test/language/statements/class/decorator/getter/private/instance/context-private-false.js create mode 100644 test/language/statements/class/decorator/getter/private/instance/context-static-false.js create mode 100644 test/language/statements/class/decorator/getter/private/instance/getter-deco-returns-replacement.js create mode 100644 test/language/statements/class/decorator/getter/private/instance/getter-deco-returns-undefined.js create mode 100644 test/language/statements/class/decorator/getter/public/instance/context-kind-getter.js create mode 100644 test/language/statements/class/decorator/getter/public/instance/context-name-public.js create mode 100644 test/language/statements/class/decorator/getter/public/instance/context-private-true.js create mode 100644 test/language/statements/class/decorator/getter/public/instance/context-static-false.js create mode 100644 test/language/statements/class/decorator/getter/public/instance/getter-deco-returns-replacement.js create mode 100644 test/language/statements/class/decorator/getter/public/instance/getter-deco-returns-undefined.js create mode 100644 test/language/statements/class/decorator/getter/public/static/context-kind-getter.js create mode 100644 test/language/statements/class/decorator/getter/public/static/context-name-public.js create mode 100644 test/language/statements/class/decorator/getter/public/static/context-private-true.js create mode 100644 test/language/statements/class/decorator/getter/public/static/context-static-true.js create mode 100644 test/language/statements/class/decorator/getter/public/static/getter-deco-returns-replacement.js create mode 100644 test/language/statements/class/decorator/getter/public/static/getter-deco-returns-undefined.js create mode 100644 test/language/statements/class/decorator/method/async/private/instance/context-kind-method.js create mode 100644 test/language/statements/class/decorator/method/async/private/instance/method-async-deco-returns-replacement.js create mode 100644 test/language/statements/class/decorator/method/async/private/instance/method-async-deco-returns-undefined.js create mode 100644 test/language/statements/class/decorator/method/async/private/static/context-kind-method.js create mode 100644 test/language/statements/class/decorator/method/async/private/static/method-async-deco-returns-replacement.js create mode 100644 test/language/statements/class/decorator/method/async/private/static/method-async-deco-returns-undefined.js create mode 100644 test/language/statements/class/decorator/method/async/public/instance/context-kind-method.js create mode 100644 test/language/statements/class/decorator/method/async/public/instance/method-async-deco-returns-replacement.js create mode 100644 test/language/statements/class/decorator/method/async/public/instance/method-async-deco-returns-undefined.js create mode 100644 test/language/statements/class/decorator/method/async/public/static/context-kind-method.js create mode 100644 test/language/statements/class/decorator/method/async/public/static/method-async-deco-returns-replacement.js create mode 100644 test/language/statements/class/decorator/method/async/public/static/method-async-deco-returns-undefined.js create mode 100644 test/language/statements/class/decorator/method/error/private/instance/method-deco-returns-invalid.js create mode 100644 test/language/statements/class/decorator/method/error/private/static/method-deco-returns-invalid.js create mode 100644 test/language/statements/class/decorator/method/error/public/instance/method-deco-returns-invalid.js create mode 100644 test/language/statements/class/decorator/method/error/public/static/method-deco-returns-invalid.js create mode 100644 test/language/statements/class/decorator/method/private/instance/context-access-get.js create mode 100644 test/language/statements/class/decorator/method/private/instance/context-kind-method.js create mode 100644 test/language/statements/class/decorator/method/private/instance/context-name-private.js create mode 100644 test/language/statements/class/decorator/method/private/instance/context-private-false.js create mode 100644 test/language/statements/class/decorator/method/private/instance/context-static-false.js create mode 100644 test/language/statements/class/decorator/method/private/instance/decorator-order-application-method-and-class.js create mode 100644 test/language/statements/class/decorator/method/private/instance/method-deco-returns-replacement.js create mode 100644 test/language/statements/class/decorator/method/private/instance/method-deco-returns-undefined.js create mode 100644 test/language/statements/class/decorator/method/private/instance/method-generator-deco-returns-replacement.js create mode 100644 test/language/statements/class/decorator/method/private/instance/method-generator-deco-returns-undefined.js create mode 100644 test/language/statements/class/decorator/method/private/static/context-access-get.js create mode 100644 test/language/statements/class/decorator/method/private/static/context-kind-method.js create mode 100644 test/language/statements/class/decorator/method/private/static/context-name-private.js create mode 100644 test/language/statements/class/decorator/method/private/static/context-private-false.js create mode 100644 test/language/statements/class/decorator/method/private/static/context-static-true.js create mode 100644 test/language/statements/class/decorator/method/private/static/decorator-order-application-method-and-class.js create mode 100644 test/language/statements/class/decorator/method/private/static/method-deco-returns-replacement.js create mode 100644 test/language/statements/class/decorator/method/private/static/method-deco-returns-undefined.js create mode 100644 test/language/statements/class/decorator/method/private/static/method-generator-deco-returns-replacement.js create mode 100644 test/language/statements/class/decorator/method/private/static/method-generator-deco-returns-undefined.js create mode 100644 test/language/statements/class/decorator/method/public/instance/context-access-get.js create mode 100644 test/language/statements/class/decorator/method/public/instance/context-kind-method.js create mode 100644 test/language/statements/class/decorator/method/public/instance/context-name-public.js create mode 100644 test/language/statements/class/decorator/method/public/instance/context-private-true.js create mode 100644 test/language/statements/class/decorator/method/public/instance/context-static-false.js create mode 100644 test/language/statements/class/decorator/method/public/instance/decorator-order-application-method-and-class.js create mode 100644 test/language/statements/class/decorator/method/public/instance/method-deco-returns-replacement.js create mode 100644 test/language/statements/class/decorator/method/public/instance/method-deco-returns-undefined.js create mode 100644 test/language/statements/class/decorator/method/public/instance/method-generator-deco-returns-replacement.js create mode 100644 test/language/statements/class/decorator/method/public/instance/method-generator-deco-returns-undefined.js create mode 100644 test/language/statements/class/decorator/method/public/static/context-access-get.js create mode 100644 test/language/statements/class/decorator/method/public/static/context-kind-method.js create mode 100644 test/language/statements/class/decorator/method/public/static/context-name-public.js create mode 100644 test/language/statements/class/decorator/method/public/static/context-private-true.js create mode 100644 test/language/statements/class/decorator/method/public/static/context-static-true.js create mode 100644 test/language/statements/class/decorator/method/public/static/decorator-order-application-method-and-class.js create mode 100644 test/language/statements/class/decorator/method/public/static/method-deco-returns-replacement.js create mode 100644 test/language/statements/class/decorator/method/public/static/method-deco-returns-undefined.js create mode 100644 test/language/statements/class/decorator/method/public/static/method-generator-deco-returns-replacement.js create mode 100644 test/language/statements/class/decorator/method/public/static/method-generator-deco-returns-undefined.js create mode 100644 test/language/statements/class/decorator/setter/error/private/instance/setter-deco-returns-invalid.js create mode 100644 test/language/statements/class/decorator/setter/error/private/static/setter-deco-returns-invalid.js create mode 100644 test/language/statements/class/decorator/setter/error/public/instance/setter-deco-returns-invalid.js create mode 100644 test/language/statements/class/decorator/setter/error/public/static/setter-deco-returns-invalid.js create mode 100644 test/language/statements/class/decorator/setter/private/instance/context-access-set.js create mode 100644 test/language/statements/class/decorator/setter/private/instance/context-kind-setter.js create mode 100644 test/language/statements/class/decorator/setter/private/instance/context-name-private.js create mode 100644 test/language/statements/class/decorator/setter/private/instance/context-private-false.js create mode 100644 test/language/statements/class/decorator/setter/private/instance/context-static-false.js create mode 100644 test/language/statements/class/decorator/setter/private/instance/setter-deco-returns-replacement.js create mode 100644 test/language/statements/class/decorator/setter/private/instance/setter-deco-returns-undefined.js create mode 100644 test/language/statements/class/decorator/setter/private/static/context-access-set.js create mode 100644 test/language/statements/class/decorator/setter/private/static/context-kind-setter.js create mode 100644 test/language/statements/class/decorator/setter/private/static/context-name-private.js create mode 100644 test/language/statements/class/decorator/setter/private/static/context-private-false.js create mode 100644 test/language/statements/class/decorator/setter/private/static/context-static-true.js create mode 100644 test/language/statements/class/decorator/setter/private/static/setter-deco-returns-replacement.js create mode 100644 test/language/statements/class/decorator/setter/private/static/setter-deco-returns-undefined.js create mode 100644 test/language/statements/class/decorator/setter/public/instance/context-access-set.js create mode 100644 test/language/statements/class/decorator/setter/public/instance/context-kind-setter.js create mode 100644 test/language/statements/class/decorator/setter/public/instance/context-name-public.js create mode 100644 test/language/statements/class/decorator/setter/public/instance/context-private-true.js create mode 100644 test/language/statements/class/decorator/setter/public/instance/context-static-false.js create mode 100644 test/language/statements/class/decorator/setter/public/instance/setter-deco-returns-replacement.js create mode 100644 test/language/statements/class/decorator/setter/public/instance/setter-deco-returns-undefined.js create mode 100644 test/language/statements/class/decorator/setter/public/static/context-access-set.js create mode 100644 test/language/statements/class/decorator/setter/public/static/context-kind-setter.js create mode 100644 test/language/statements/class/decorator/setter/public/static/context-name-public.js create mode 100644 test/language/statements/class/decorator/setter/public/static/context-private-true.js create mode 100644 test/language/statements/class/decorator/setter/public/static/context-static-true.js create mode 100644 test/language/statements/class/decorator/setter/public/static/setter-deco-returns-replacement.js create mode 100644 test/language/statements/class/decorator/setter/public/static/setter-deco-returns-undefined.js diff --git a/test/language/expressions/class/decorator/accessor/error/private/instance/accessor-deco-invalid-return-get.js b/test/language/expressions/class/decorator/accessor/error/private/instance/accessor-deco-invalid-return-get.js new file mode 100644 index 00000000000..769eb4d8305 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/error/private/instance/accessor-deco-invalid-return-get.js @@ -0,0 +1,28 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-invalid-return-get.case +// - src/decorator/accessors/error/private/instance/cls-expr.template +/*--- +description: Accessor decorator cannot return invalid getter (private acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec() { + return { + get: 123 + }; +} + + +function evaluate() { + var C = class { + @dec + + accessor #element; + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/expressions/class/decorator/accessor/error/private/instance/accessor-deco-invalid-return-init.js b/test/language/expressions/class/decorator/accessor/error/private/instance/accessor-deco-invalid-return-init.js new file mode 100644 index 00000000000..7fda5c473bb --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/error/private/instance/accessor-deco-invalid-return-init.js @@ -0,0 +1,28 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-invalid-return-init.case +// - src/decorator/accessors/error/private/instance/cls-expr.template +/*--- +description: Accessor decorator cannot return invalid init (private acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec() { + return { + init: 123 + }; +} + + +function evaluate() { + var C = class { + @dec + + accessor #element; + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/expressions/class/decorator/accessor/error/private/instance/accessor-deco-invalid-return-set.js b/test/language/expressions/class/decorator/accessor/error/private/instance/accessor-deco-invalid-return-set.js new file mode 100644 index 00000000000..a74a3b222a3 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/error/private/instance/accessor-deco-invalid-return-set.js @@ -0,0 +1,28 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-invalid-return-set.case +// - src/decorator/accessors/error/private/instance/cls-expr.template +/*--- +description: Accessor decorator cannot return invalid setter (private acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec() { + return { + set: 123 + }; +} + + +function evaluate() { + var C = class { + @dec + + accessor #element; + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/expressions/class/decorator/accessor/error/private/instance/accessor-deco-invalid-return.js b/test/language/expressions/class/decorator/accessor/error/private/instance/accessor-deco-invalid-return.js new file mode 100644 index 00000000000..6e2d8e91bbe --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/error/private/instance/accessor-deco-invalid-return.js @@ -0,0 +1,26 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-invalid-return.case +// - src/decorator/accessors/error/private/instance/cls-expr.template +/*--- +description: Accessor decorator cannot return invalid init (private acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec() { + return 123; +} + + +function evaluate() { + var C = class { + @dec + + accessor #element; + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/expressions/class/decorator/accessor/error/private/static/accessor-deco-invalid-return-get.js b/test/language/expressions/class/decorator/accessor/error/private/static/accessor-deco-invalid-return-get.js new file mode 100644 index 00000000000..dd1d6407b98 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/error/private/static/accessor-deco-invalid-return-get.js @@ -0,0 +1,27 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-invalid-return-get.case +// - src/decorator/accessors/error/private/static/cls-expr.template +/*--- +description: Accessor decorator cannot return invalid getter (private static acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec() { + return { + get: 123 + }; +} + + +function evaluate() { + var C = class { + @dec + + static accessor #element; + } +} + +assert.throws(TypeError, evaluate); diff --git a/test/language/expressions/class/decorator/accessor/error/private/static/accessor-deco-invalid-return-init.js b/test/language/expressions/class/decorator/accessor/error/private/static/accessor-deco-invalid-return-init.js new file mode 100644 index 00000000000..566209190e2 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/error/private/static/accessor-deco-invalid-return-init.js @@ -0,0 +1,27 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-invalid-return-init.case +// - src/decorator/accessors/error/private/static/cls-expr.template +/*--- +description: Accessor decorator cannot return invalid init (private static acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec() { + return { + init: 123 + }; +} + + +function evaluate() { + var C = class { + @dec + + static accessor #element; + } +} + +assert.throws(TypeError, evaluate); diff --git a/test/language/expressions/class/decorator/accessor/error/private/static/accessor-deco-invalid-return-set.js b/test/language/expressions/class/decorator/accessor/error/private/static/accessor-deco-invalid-return-set.js new file mode 100644 index 00000000000..b9badf1e9cc --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/error/private/static/accessor-deco-invalid-return-set.js @@ -0,0 +1,27 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-invalid-return-set.case +// - src/decorator/accessors/error/private/static/cls-expr.template +/*--- +description: Accessor decorator cannot return invalid setter (private static acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec() { + return { + set: 123 + }; +} + + +function evaluate() { + var C = class { + @dec + + static accessor #element; + } +} + +assert.throws(TypeError, evaluate); diff --git a/test/language/expressions/class/decorator/accessor/error/private/static/accessor-deco-invalid-return.js b/test/language/expressions/class/decorator/accessor/error/private/static/accessor-deco-invalid-return.js new file mode 100644 index 00000000000..109b4263c9a --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/error/private/static/accessor-deco-invalid-return.js @@ -0,0 +1,25 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-invalid-return.case +// - src/decorator/accessors/error/private/static/cls-expr.template +/*--- +description: Accessor decorator cannot return invalid init (private static acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec() { + return 123; +} + + +function evaluate() { + var C = class { + @dec + + static accessor #element; + } +} + +assert.throws(TypeError, evaluate); diff --git a/test/language/expressions/class/decorator/accessor/error/public/instance/accessor-deco-invalid-return-get.js b/test/language/expressions/class/decorator/accessor/error/public/instance/accessor-deco-invalid-return-get.js new file mode 100644 index 00000000000..da251e2a51b --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/error/public/instance/accessor-deco-invalid-return-get.js @@ -0,0 +1,28 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-invalid-return-get.case +// - src/decorator/accessors/error/public/instance/cls-expr.template +/*--- +description: Accessor decorator cannot return invalid getter (public acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec() { + return { + get: 123 + }; +} + + +function evaluate() { + var C = class { + @dec + + accessor element; + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/expressions/class/decorator/accessor/error/public/instance/accessor-deco-invalid-return-init.js b/test/language/expressions/class/decorator/accessor/error/public/instance/accessor-deco-invalid-return-init.js new file mode 100644 index 00000000000..bae0dbe3b37 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/error/public/instance/accessor-deco-invalid-return-init.js @@ -0,0 +1,28 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-invalid-return-init.case +// - src/decorator/accessors/error/public/instance/cls-expr.template +/*--- +description: Accessor decorator cannot return invalid init (public acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec() { + return { + init: 123 + }; +} + + +function evaluate() { + var C = class { + @dec + + accessor element; + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/expressions/class/decorator/accessor/error/public/instance/accessor-deco-invalid-return-set.js b/test/language/expressions/class/decorator/accessor/error/public/instance/accessor-deco-invalid-return-set.js new file mode 100644 index 00000000000..9327cf5be69 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/error/public/instance/accessor-deco-invalid-return-set.js @@ -0,0 +1,28 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-invalid-return-set.case +// - src/decorator/accessors/error/public/instance/cls-expr.template +/*--- +description: Accessor decorator cannot return invalid setter (public acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec() { + return { + set: 123 + }; +} + + +function evaluate() { + var C = class { + @dec + + accessor element; + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/expressions/class/decorator/accessor/error/public/instance/accessor-deco-invalid-return.js b/test/language/expressions/class/decorator/accessor/error/public/instance/accessor-deco-invalid-return.js new file mode 100644 index 00000000000..0e47493cc08 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/error/public/instance/accessor-deco-invalid-return.js @@ -0,0 +1,26 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-invalid-return.case +// - src/decorator/accessors/error/public/instance/cls-expr.template +/*--- +description: Accessor decorator cannot return invalid init (public acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec() { + return 123; +} + + +function evaluate() { + var C = class { + @dec + + accessor element; + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/expressions/class/decorator/accessor/private/instance/accessor-deco-returns-get.js b/test/language/expressions/class/decorator/accessor/private/instance/accessor-deco-returns-get.js new file mode 100644 index 00000000000..d7d52804a9e --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/private/instance/accessor-deco-returns-get.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-returns-get.case +// - src/decorator/accessors/standard/private/instance/cls-expr.template +/*--- +description: Accessor decorator can return a new getter (private acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec({ get }) { + return { + get() { + assert.sameValue(get.call(this), undefined); + return 123; + } + }; +} + + +var C = class { + @dec + + accessor #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 123); diff --git a/test/language/expressions/class/decorator/accessor/private/instance/accessor-deco-returns-init.js b/test/language/expressions/class/decorator/accessor/private/instance/accessor-deco-returns-init.js new file mode 100644 index 00000000000..012bf6c24b9 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/private/instance/accessor-deco-returns-init.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-returns-init.case +// - src/decorator/accessors/standard/private/instance/cls-expr.template +/*--- +description: Accessor decorator can return a new init (private acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec() { + return { + init(value) { + assert.sameValue(value, undefined); + return 123; + } + }; +} + + +var C = class { + @dec + + accessor #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 123); +classOrInstance.setElement(456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/accessor/private/instance/accessor-deco-returns-set.js b/test/language/expressions/class/decorator/accessor/private/instance/accessor-deco-returns-set.js new file mode 100644 index 00000000000..573f5d30fc6 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/private/instance/accessor-deco-returns-set.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-returns-set.case +// - src/decorator/accessors/standard/private/instance/cls-expr.template +/*--- +description: Accessor decorator can return a new getter (private acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec({ set }) { + return { + set(value) { + assert.sameValue(value, 123); + set.call(this, 456); + } + }; +} + + +var C = class { + @dec + + accessor #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), undefined); +classOrInstance.setElement(123); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/accessor/private/instance/context-access-get.js b/test/language/expressions/class/decorator/accessor/private/instance/context-access-get.js new file mode 100644 index 00000000000..82accda0f7e --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/private/instance/context-access-get.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-get.case +// - src/decorator/accessors/standard/private/instance/cls-expr.template +/*--- +description: Context access `get` works on all gettable types of values (private acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +var C = class { + @dec + + accessor #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), access.get(classOrInstance)); diff --git a/test/language/expressions/class/decorator/accessor/private/instance/context-access-set.js b/test/language/expressions/class/decorator/accessor/private/instance/context-access-set.js new file mode 100644 index 00000000000..b5cd6e00edd --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/private/instance/context-access-set.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-set.case +// - src/decorator/accessors/standard/private/instance/cls-expr.template +/*--- +description: Context access `get` works on all gettable types of values (private acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +var C = class { + @dec + + accessor #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/accessor/private/instance/context-kind-accessor.js b/test/language/expressions/class/decorator/accessor/private/instance/context-kind-accessor.js new file mode 100644 index 00000000000..1b35500253f --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/private/instance/context-kind-accessor.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-accessor.case +// - src/decorator/accessors/standard/private/instance/cls-expr.template +/*--- +description: Context kind is the string "accessor" when decorating a method (private acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "accessor"); +} + + +var C = class { + @dec + accessor #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/accessor/private/instance/context-name-private.js b/test/language/expressions/class/decorator/accessor/private/instance/context-name-private.js new file mode 100644 index 00000000000..788a7b49c3c --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/private/instance/context-name-private.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-private.case +// - src/decorator/accessors/standard/private/instance/cls-expr.template +/*--- +description: Context name is correct for all types of private elements (private acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "#element"); +} + + +var C = class { + @dec + accessor #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/accessor/private/instance/context-private-false.js b/test/language/expressions/class/decorator/accessor/private/instance/context-private-false.js new file mode 100644 index 00000000000..c2cee9a83f7 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/private/instance/context-private-false.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-private-false.case +// - src/decorator/accessors/standard/private/instance/cls-expr.template +/*--- +description: Context `private` is true for all types of private elements (private acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.private, true); +} + + +var C = class { + @dec + accessor #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/accessor/private/instance/context-static-false.js b/test/language/expressions/class/decorator/accessor/private/instance/context-static-false.js new file mode 100644 index 00000000000..0fe14015658 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/private/instance/context-static-false.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-static-false.case +// - src/decorator/accessors/standard/private/instance/cls-expr.template +/*--- +description: Context `static` is false for all types of instance elements (private acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.static, false); +} + + +var C = class { + @dec + accessor #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/accessor/private/instance/field-and-accessor-init-this.js b/test/language/expressions/class/decorator/accessor/private/instance/field-and-accessor-init-this.js new file mode 100644 index 00000000000..69b3a5e4da9 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/private/instance/field-and-accessor-init-this.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/accessors/standard/private/instance/cls-expr.template +/*--- +description: Field initializer `this` value is the instance or the class (private acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +var C = class { + @dec + + accessor #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/expressions/class/decorator/accessor/private/static/accessor-deco-returns-get.js b/test/language/expressions/class/decorator/accessor/private/static/accessor-deco-returns-get.js new file mode 100644 index 00000000000..8afdbfad073 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/private/static/accessor-deco-returns-get.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-returns-get.case +// - src/decorator/accessors/standard/private/static/cls-expr.template +/*--- +description: Accessor decorator can return a new getter (private static acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec({ get }) { + return { + get() { + assert.sameValue(get.call(this), undefined); + return 123; + } + }; +} + + +var C = class { + @dec + + static accessor #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 123); diff --git a/test/language/expressions/class/decorator/accessor/private/static/accessor-deco-returns-init.js b/test/language/expressions/class/decorator/accessor/private/static/accessor-deco-returns-init.js new file mode 100644 index 00000000000..5ab550d6313 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/private/static/accessor-deco-returns-init.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-returns-init.case +// - src/decorator/accessors/standard/private/static/cls-expr.template +/*--- +description: Accessor decorator can return a new init (private static acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec() { + return { + init(value) { + assert.sameValue(value, undefined); + return 123; + } + }; +} + + +var C = class { + @dec + + static accessor #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 123); +classOrInstance.setElement(456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/accessor/private/static/accessor-deco-returns-set.js b/test/language/expressions/class/decorator/accessor/private/static/accessor-deco-returns-set.js new file mode 100644 index 00000000000..6e9bdce5654 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/private/static/accessor-deco-returns-set.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-returns-set.case +// - src/decorator/accessors/standard/private/static/cls-expr.template +/*--- +description: Accessor decorator can return a new getter (private static acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec({ set }) { + return { + set(value) { + assert.sameValue(value, 123); + set.call(this, 456); + } + }; +} + + +var C = class { + @dec + + static accessor #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), undefined); +classOrInstance.setElement(123); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/accessor/private/static/context-access-get.js b/test/language/expressions/class/decorator/accessor/private/static/context-access-get.js new file mode 100644 index 00000000000..2397dc8cfa0 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/private/static/context-access-get.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-get.case +// - src/decorator/accessors/standard/private/static/cls-expr.template +/*--- +description: Context access `get` works on all gettable types of values (private static acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +var C = class { + @dec + + static accessor #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), access.get(classOrInstance)); diff --git a/test/language/expressions/class/decorator/accessor/private/static/context-access-set.js b/test/language/expressions/class/decorator/accessor/private/static/context-access-set.js new file mode 100644 index 00000000000..eb34c318832 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/private/static/context-access-set.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-set.case +// - src/decorator/accessors/standard/private/static/cls-expr.template +/*--- +description: Context access `get` works on all gettable types of values (private static acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +var C = class { + @dec + + static accessor #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/accessor/private/static/context-kind-accessor.js b/test/language/expressions/class/decorator/accessor/private/static/context-kind-accessor.js new file mode 100644 index 00000000000..813ecd482d3 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/private/static/context-kind-accessor.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-accessor.case +// - src/decorator/accessors/standard/private/static/cls-expr.template +/*--- +description: Context kind is the string "accessor" when decorating a method (private static acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "accessor"); +} + + +var C = class { + @dec + static accessor #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/accessor/private/static/context-name-private.js b/test/language/expressions/class/decorator/accessor/private/static/context-name-private.js new file mode 100644 index 00000000000..f3c6221c863 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/private/static/context-name-private.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-private.case +// - src/decorator/accessors/standard/private/static/cls-expr.template +/*--- +description: Context name is correct for all types of private elements (private static acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "#element"); +} + + +var C = class { + @dec + static accessor #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/accessor/private/static/context-private-false.js b/test/language/expressions/class/decorator/accessor/private/static/context-private-false.js new file mode 100644 index 00000000000..3684c144664 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/private/static/context-private-false.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-private-false.case +// - src/decorator/accessors/standard/private/static/cls-expr.template +/*--- +description: Context `private` is true for all types of private elements (private static acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.private, true); +} + + +var C = class { + @dec + static accessor #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/accessor/private/static/context-static-true.js b/test/language/expressions/class/decorator/accessor/private/static/context-static-true.js new file mode 100644 index 00000000000..6408fb52098 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/private/static/context-static-true.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-static-true.case +// - src/decorator/accessors/standard/private/static/cls-expr.template +/*--- +description: Context `static` is false for all types of instance elements (private static acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.static, true); +} + + +var C = class { + @dec + static accessor #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/accessor/private/static/field-and-accessor-init-this.js b/test/language/expressions/class/decorator/accessor/private/static/field-and-accessor-init-this.js new file mode 100644 index 00000000000..6ee32121421 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/private/static/field-and-accessor-init-this.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/accessors/standard/private/static/cls-expr.template +/*--- +description: Field initializer `this` value is the instance or the class (private static acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +var C = class { + @dec + + static accessor #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/expressions/class/decorator/accessor/public/instance/accessor-deco-returns-get.js b/test/language/expressions/class/decorator/accessor/public/instance/accessor-deco-returns-get.js new file mode 100644 index 00000000000..39d57684ee2 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/public/instance/accessor-deco-returns-get.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-returns-get.case +// - src/decorator/accessors/standard/public/instance/cls-expr.template +/*--- +description: Accessor decorator can return a new getter (public acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec({ get }) { + return { + get() { + assert.sameValue(get.call(this), undefined); + return 123; + } + }; +} + + +var C = class { + @dec + + accessor element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 123); diff --git a/test/language/expressions/class/decorator/accessor/public/instance/accessor-deco-returns-init.js b/test/language/expressions/class/decorator/accessor/public/instance/accessor-deco-returns-init.js new file mode 100644 index 00000000000..b623a3b389d --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/public/instance/accessor-deco-returns-init.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-returns-init.case +// - src/decorator/accessors/standard/public/instance/cls-expr.template +/*--- +description: Accessor decorator can return a new init (public acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec() { + return { + init(value) { + assert.sameValue(value, undefined); + return 123; + } + }; +} + + +var C = class { + @dec + + accessor element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 123); +classOrInstance.setElement(456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/accessor/public/instance/accessor-deco-returns-set.js b/test/language/expressions/class/decorator/accessor/public/instance/accessor-deco-returns-set.js new file mode 100644 index 00000000000..26da9df3b0e --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/public/instance/accessor-deco-returns-set.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-returns-set.case +// - src/decorator/accessors/standard/public/instance/cls-expr.template +/*--- +description: Accessor decorator can return a new getter (public acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec({ set }) { + return { + set(value) { + assert.sameValue(value, 123); + set.call(this, 456); + } + }; +} + + +var C = class { + @dec + + accessor element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), undefined); +classOrInstance.setElement(123); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/accessor/public/instance/context-access-get.js b/test/language/expressions/class/decorator/accessor/public/instance/context-access-get.js new file mode 100644 index 00000000000..f88f9afe4a9 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/public/instance/context-access-get.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-get.case +// - src/decorator/accessors/standard/public/instance/cls-expr.template +/*--- +description: Context access `get` works on all gettable types of values (public acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +var C = class { + @dec + + accessor element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), access.get(classOrInstance)); diff --git a/test/language/expressions/class/decorator/accessor/public/instance/context-access-set.js b/test/language/expressions/class/decorator/accessor/public/instance/context-access-set.js new file mode 100644 index 00000000000..62e83029426 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/public/instance/context-access-set.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-set.case +// - src/decorator/accessors/standard/public/instance/cls-expr.template +/*--- +description: Context access `get` works on all gettable types of values (public acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +var C = class { + @dec + + accessor element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/accessor/public/instance/context-kind-accessor.js b/test/language/expressions/class/decorator/accessor/public/instance/context-kind-accessor.js new file mode 100644 index 00000000000..2b15dd1d14f --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/public/instance/context-kind-accessor.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-accessor.case +// - src/decorator/accessors/standard/public/instance/cls-expr.template +/*--- +description: Context kind is the string "accessor" when decorating a method (public acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "accessor"); +} + + +var C = class { + @dec + accessor element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/accessor/public/instance/context-name-public.js b/test/language/expressions/class/decorator/accessor/public/instance/context-name-public.js new file mode 100644 index 00000000000..2b5bd33bcc9 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/public/instance/context-name-public.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-public.case +// - src/decorator/accessors/standard/public/instance/cls-expr.template +/*--- +description: Context name is correct for all types of public elements (public acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "element"); +} + + +var C = class { + @dec + accessor element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/accessor/public/instance/context-private-true.js b/test/language/expressions/class/decorator/accessor/public/instance/context-private-true.js new file mode 100644 index 00000000000..cec463ab322 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/public/instance/context-private-true.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-private-true.case +// - src/decorator/accessors/standard/public/instance/cls-expr.template +/*--- +description: Context `private` is false for all types of public elements (public acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.private, false); +} + + +var C = class { + @dec + accessor element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/accessor/public/instance/context-static-false.js b/test/language/expressions/class/decorator/accessor/public/instance/context-static-false.js new file mode 100644 index 00000000000..a419b7e226a --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/public/instance/context-static-false.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-static-false.case +// - src/decorator/accessors/standard/public/instance/cls-expr.template +/*--- +description: Context `static` is false for all types of instance elements (public acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.static, false); +} + + +var C = class { + @dec + accessor element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/accessor/public/instance/field-and-accessor-init-this.js b/test/language/expressions/class/decorator/accessor/public/instance/field-and-accessor-init-this.js new file mode 100644 index 00000000000..4e4ee7a691a --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/public/instance/field-and-accessor-init-this.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/accessors/standard/public/instance/cls-expr.template +/*--- +description: Field initializer `this` value is the instance or the class (public acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +var C = class { + @dec + + accessor element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/expressions/class/decorator/accessor/public/static/accessor-deco-invalid-return-get.js b/test/language/expressions/class/decorator/accessor/public/static/accessor-deco-invalid-return-get.js new file mode 100644 index 00000000000..154337ed4b3 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/public/static/accessor-deco-invalid-return-get.js @@ -0,0 +1,27 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-invalid-return-get.case +// - src/decorator/accessors/error/public/static/cls-expr.template +/*--- +description: Accessor decorator cannot return invalid getter (public static acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec() { + return { + get: 123 + }; +} + + +function evaluate() { + var C = class { + @dec + + static accessor element; + } +} + +assert.throws(TypeError, evaluate); diff --git a/test/language/expressions/class/decorator/accessor/public/static/accessor-deco-invalid-return-init.js b/test/language/expressions/class/decorator/accessor/public/static/accessor-deco-invalid-return-init.js new file mode 100644 index 00000000000..6b2d524da8a --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/public/static/accessor-deco-invalid-return-init.js @@ -0,0 +1,27 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-invalid-return-init.case +// - src/decorator/accessors/error/public/static/cls-expr.template +/*--- +description: Accessor decorator cannot return invalid init (public static acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec() { + return { + init: 123 + }; +} + + +function evaluate() { + var C = class { + @dec + + static accessor element; + } +} + +assert.throws(TypeError, evaluate); diff --git a/test/language/expressions/class/decorator/accessor/public/static/accessor-deco-invalid-return-set.js b/test/language/expressions/class/decorator/accessor/public/static/accessor-deco-invalid-return-set.js new file mode 100644 index 00000000000..21a52e1a04b --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/public/static/accessor-deco-invalid-return-set.js @@ -0,0 +1,27 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-invalid-return-set.case +// - src/decorator/accessors/error/public/static/cls-expr.template +/*--- +description: Accessor decorator cannot return invalid setter (public static acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec() { + return { + set: 123 + }; +} + + +function evaluate() { + var C = class { + @dec + + static accessor element; + } +} + +assert.throws(TypeError, evaluate); diff --git a/test/language/expressions/class/decorator/accessor/public/static/accessor-deco-invalid-return.js b/test/language/expressions/class/decorator/accessor/public/static/accessor-deco-invalid-return.js new file mode 100644 index 00000000000..9b795b29566 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/public/static/accessor-deco-invalid-return.js @@ -0,0 +1,25 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-invalid-return.case +// - src/decorator/accessors/error/public/static/cls-expr.template +/*--- +description: Accessor decorator cannot return invalid init (public static acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec() { + return 123; +} + + +function evaluate() { + var C = class { + @dec + + static accessor element; + } +} + +assert.throws(TypeError, evaluate); diff --git a/test/language/expressions/class/decorator/accessor/public/static/accessor-deco-returns-get.js b/test/language/expressions/class/decorator/accessor/public/static/accessor-deco-returns-get.js new file mode 100644 index 00000000000..b07fa0bc542 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/public/static/accessor-deco-returns-get.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-returns-get.case +// - src/decorator/accessors/standard/public/static/cls-expr.template +/*--- +description: Accessor decorator can return a new getter (public static acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec({ get }) { + return { + get() { + assert.sameValue(get.call(this), undefined); + return 123; + } + }; +} + + +var C = class { + @dec + + static accessor element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 123); diff --git a/test/language/expressions/class/decorator/accessor/public/static/accessor-deco-returns-init.js b/test/language/expressions/class/decorator/accessor/public/static/accessor-deco-returns-init.js new file mode 100644 index 00000000000..092b9332627 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/public/static/accessor-deco-returns-init.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-returns-init.case +// - src/decorator/accessors/standard/public/static/cls-expr.template +/*--- +description: Accessor decorator can return a new init (public static acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec() { + return { + init(value) { + assert.sameValue(value, undefined); + return 123; + } + }; +} + + +var C = class { + @dec + + static accessor element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 123); +classOrInstance.setElement(456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/accessor/public/static/accessor-deco-returns-set.js b/test/language/expressions/class/decorator/accessor/public/static/accessor-deco-returns-set.js new file mode 100644 index 00000000000..7f472b62f5f --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/public/static/accessor-deco-returns-set.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-returns-set.case +// - src/decorator/accessors/standard/public/static/cls-expr.template +/*--- +description: Accessor decorator can return a new getter (public static acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec({ set }) { + return { + set(value) { + assert.sameValue(value, 123); + set.call(this, 456); + } + }; +} + + +var C = class { + @dec + + static accessor element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), undefined); +classOrInstance.setElement(123); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/accessor/public/static/context-access-get.js b/test/language/expressions/class/decorator/accessor/public/static/context-access-get.js new file mode 100644 index 00000000000..9d54a958dba --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/public/static/context-access-get.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-get.case +// - src/decorator/accessors/standard/public/static/cls-expr.template +/*--- +description: Context access `get` works on all gettable types of values (public static acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +var C = class { + @dec + + static accessor element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), access.get(classOrInstance)); diff --git a/test/language/expressions/class/decorator/accessor/public/static/context-access-set.js b/test/language/expressions/class/decorator/accessor/public/static/context-access-set.js new file mode 100644 index 00000000000..18d80a81929 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/public/static/context-access-set.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-set.case +// - src/decorator/accessors/standard/public/static/cls-expr.template +/*--- +description: Context access `get` works on all gettable types of values (public static acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +var C = class { + @dec + + static accessor element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/accessor/public/static/context-kind-accessor.js b/test/language/expressions/class/decorator/accessor/public/static/context-kind-accessor.js new file mode 100644 index 00000000000..63c0c1bc386 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/public/static/context-kind-accessor.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-accessor.case +// - src/decorator/accessors/standard/public/static/cls-expr.template +/*--- +description: Context kind is the string "accessor" when decorating a method (public static acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "accessor"); +} + + +var C = class { + @dec + static accessor element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/accessor/public/static/context-name-public.js b/test/language/expressions/class/decorator/accessor/public/static/context-name-public.js new file mode 100644 index 00000000000..445d994b9b9 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/public/static/context-name-public.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-public.case +// - src/decorator/accessors/standard/public/static/cls-expr.template +/*--- +description: Context name is correct for all types of public elements (public static acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "element"); +} + + +var C = class { + @dec + static accessor element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/accessor/public/static/context-private-true.js b/test/language/expressions/class/decorator/accessor/public/static/context-private-true.js new file mode 100644 index 00000000000..06d0daa4da9 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/public/static/context-private-true.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-private-true.case +// - src/decorator/accessors/standard/public/static/cls-expr.template +/*--- +description: Context `private` is false for all types of public elements (public static acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.private, false); +} + + +var C = class { + @dec + static accessor element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/accessor/public/static/context-static-true.js b/test/language/expressions/class/decorator/accessor/public/static/context-static-true.js new file mode 100644 index 00000000000..e12b6d4c73b --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/public/static/context-static-true.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-static-true.case +// - src/decorator/accessors/standard/public/static/cls-expr.template +/*--- +description: Context `static` is false for all types of instance elements (public static acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.static, true); +} + + +var C = class { + @dec + static accessor element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/accessor/public/static/field-and-accessor-init-this.js b/test/language/expressions/class/decorator/accessor/public/static/field-and-accessor-init-this.js new file mode 100644 index 00000000000..7cff1fb3db9 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/public/static/field-and-accessor-init-this.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/accessors/standard/public/static/cls-expr.template +/*--- +description: Field initializer `this` value is the instance or the class (public static acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +var C = class { + @dec + + static accessor element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/expressions/class/decorator/accessor/with-init/private/instance/accessor-with-init-deco-returns-get.js b/test/language/expressions/class/decorator/accessor/with-init/private/instance/accessor-with-init-deco-returns-get.js new file mode 100644 index 00000000000..00e42e35233 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/with-init/private/instance/accessor-with-init-deco-returns-get.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-with-init-deco-returns-get.case +// - src/decorator/accessors/with-init/private/instance/cls-expr.template +/*--- +description: Accessor decorator can return a new getter (private accessor with initializer decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec({ get }) { + return { + get() { + assert.sameValue(get.call(this), 123); + return 456; + } + }; +} + + +var C = class { + @dec + + accessor #element = 123 +; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/accessor/with-init/private/instance/accessor-with-init-deco-returns-init.js b/test/language/expressions/class/decorator/accessor/with-init/private/instance/accessor-with-init-deco-returns-init.js new file mode 100644 index 00000000000..25caff40e3f --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/with-init/private/instance/accessor-with-init-deco-returns-init.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-with-init-deco-returns-init.case +// - src/decorator/accessors/with-init/private/instance/cls-expr.template +/*--- +description: Accessor decorator can return a new init that chains with default initializer (private accessor with initializer decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec({ get, set }) { + return { + init(value) { + assert.sameValue(value, 123); + return 456; + } + }; +} + + +var C = class { + @dec + + accessor #element = 123 +; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 456); +classOrInstance.setElement(789); +assert.sameValue(classOrInstance.getElement(), 789); diff --git a/test/language/expressions/class/decorator/accessor/with-init/private/instance/accessor-with-init-deco-returns-set.js b/test/language/expressions/class/decorator/accessor/with-init/private/instance/accessor-with-init-deco-returns-set.js new file mode 100644 index 00000000000..54f1ee371bd --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/with-init/private/instance/accessor-with-init-deco-returns-set.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-with-init-deco-returns-set.case +// - src/decorator/accessors/with-init/private/instance/cls-expr.template +/*--- +description: Accessor decorator can return a new setter when initializer is present (private accessor with initializer decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec({ set }) { + return { + set(value) { + assert.sameValue(value, 456); + set.call(this, 789); + } + }; +} + + +var C = class { + @dec + + accessor #element = 123 +; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 123); +classOrInstance.setElement(456); +assert.sameValue(classOrInstance.getElement(), 789); diff --git a/test/language/expressions/class/decorator/accessor/with-init/private/instance/context-access-get.js b/test/language/expressions/class/decorator/accessor/with-init/private/instance/context-access-get.js new file mode 100644 index 00000000000..4c9fe06bcdf --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/with-init/private/instance/context-access-get.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-get.case +// - src/decorator/accessors/with-init/private/instance/cls-expr.template +/*--- +description: Context access `get` works on all gettable types of values (private accessor with initializer decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +var C = class { + @dec + + accessor #element = 123 +; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), access.get(classOrInstance)); diff --git a/test/language/expressions/class/decorator/accessor/with-init/private/instance/context-access-set.js b/test/language/expressions/class/decorator/accessor/with-init/private/instance/context-access-set.js new file mode 100644 index 00000000000..5b89aeedde2 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/with-init/private/instance/context-access-set.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-set.case +// - src/decorator/accessors/with-init/private/instance/cls-expr.template +/*--- +description: Context access `get` works on all gettable types of values (private accessor with initializer decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +var C = class { + @dec + + accessor #element = 123 +; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/accessor/with-init/private/instance/decorator-order-application-field-and-accessor.js b/test/language/expressions/class/decorator/accessor/with-init/private/instance/decorator-order-application-field-and-accessor.js new file mode 100644 index 00000000000..7e5c0b5b4fe --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/with-init/private/instance/decorator-order-application-field-and-accessor.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-order-application-field-and-accessor.case +// - src/decorator/accessors/with-init/private/instance/cls-expr.template +/*--- +description: Order of decorator application for elements with initializers (private accessor with initializer decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +var ord = []; + +function pushOrd(applyOrd, initOrd, extraInitOrd) { + return (value, context) => { + ord.push(applyOrd); + context.addInitializer(() => ord.push(extraInitOrd)); + + if (context.kind === 'field') { + return () => ord.push(initOrd); + } else { + return { + init() { + ord.push(initOrd); + } + } + } + } +} + + +var C = class { + @pushOrd(1, 3, 6) + @pushOrd(0, 4, 5) + + accessor #element = ord.push(2) +; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(ord.length, 7); +ord.forEach(assert.sameValue); diff --git a/test/language/expressions/class/decorator/accessor/with-init/private/instance/field-and-accessor-init-this.js b/test/language/expressions/class/decorator/accessor/with-init/private/instance/field-and-accessor-init-this.js new file mode 100644 index 00000000000..8694dc4f9d7 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/with-init/private/instance/field-and-accessor-init-this.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/accessors/with-init/private/instance/cls-expr.template +/*--- +description: Field initializer `this` value is the instance or the class (private accessor with initializer decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +var C = class { + @dec + + accessor #element = savedThisValues.push(this); +; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/expressions/class/decorator/accessor/with-init/private/static/accessor-with-init-deco-returns-get.js b/test/language/expressions/class/decorator/accessor/with-init/private/static/accessor-with-init-deco-returns-get.js new file mode 100644 index 00000000000..ed0a1f230b6 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/with-init/private/static/accessor-with-init-deco-returns-get.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-with-init-deco-returns-get.case +// - src/decorator/accessors/with-init/private/static/cls-expr.template +/*--- +description: Accessor decorator can return a new getter (private static with initializer acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec({ get }) { + return { + get() { + assert.sameValue(get.call(this), 123); + return 456; + } + }; +} + + +var C = class { + @dec + + static accessor #element = 123 +; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/accessor/with-init/private/static/accessor-with-init-deco-returns-init.js b/test/language/expressions/class/decorator/accessor/with-init/private/static/accessor-with-init-deco-returns-init.js new file mode 100644 index 00000000000..9e00a17e464 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/with-init/private/static/accessor-with-init-deco-returns-init.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-with-init-deco-returns-init.case +// - src/decorator/accessors/with-init/private/static/cls-expr.template +/*--- +description: Accessor decorator can return a new init that chains with default initializer (private static with initializer acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec({ get, set }) { + return { + init(value) { + assert.sameValue(value, 123); + return 456; + } + }; +} + + +var C = class { + @dec + + static accessor #element = 123 +; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 456); +classOrInstance.setElement(789); +assert.sameValue(classOrInstance.getElement(), 789); diff --git a/test/language/expressions/class/decorator/accessor/with-init/private/static/accessor-with-init-deco-returns-set.js b/test/language/expressions/class/decorator/accessor/with-init/private/static/accessor-with-init-deco-returns-set.js new file mode 100644 index 00000000000..0ea1034987d --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/with-init/private/static/accessor-with-init-deco-returns-set.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-with-init-deco-returns-set.case +// - src/decorator/accessors/with-init/private/static/cls-expr.template +/*--- +description: Accessor decorator can return a new setter when initializer is present (private static with initializer acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec({ set }) { + return { + set(value) { + assert.sameValue(value, 456); + set.call(this, 789); + } + }; +} + + +var C = class { + @dec + + static accessor #element = 123 +; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 123); +classOrInstance.setElement(456); +assert.sameValue(classOrInstance.getElement(), 789); diff --git a/test/language/expressions/class/decorator/accessor/with-init/private/static/context-access-get.js b/test/language/expressions/class/decorator/accessor/with-init/private/static/context-access-get.js new file mode 100644 index 00000000000..4deab3b778a --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/with-init/private/static/context-access-get.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-get.case +// - src/decorator/accessors/with-init/private/static/cls-expr.template +/*--- +description: Context access `get` works on all gettable types of values (private static with initializer acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +var C = class { + @dec + + static accessor #element = 123 +; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), access.get(classOrInstance)); diff --git a/test/language/expressions/class/decorator/accessor/with-init/private/static/context-access-set.js b/test/language/expressions/class/decorator/accessor/with-init/private/static/context-access-set.js new file mode 100644 index 00000000000..cd480cc8e28 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/with-init/private/static/context-access-set.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-set.case +// - src/decorator/accessors/with-init/private/static/cls-expr.template +/*--- +description: Context access `get` works on all gettable types of values (private static with initializer acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +var C = class { + @dec + + static accessor #element = 123 +; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/accessor/with-init/private/static/decorator-order-application-field-and-accessor.js b/test/language/expressions/class/decorator/accessor/with-init/private/static/decorator-order-application-field-and-accessor.js new file mode 100644 index 00000000000..28afa26d396 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/with-init/private/static/decorator-order-application-field-and-accessor.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-order-application-field-and-accessor.case +// - src/decorator/accessors/with-init/private/static/cls-expr.template +/*--- +description: Order of decorator application for elements with initializers (private static with initializer acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +var ord = []; + +function pushOrd(applyOrd, initOrd, extraInitOrd) { + return (value, context) => { + ord.push(applyOrd); + context.addInitializer(() => ord.push(extraInitOrd)); + + if (context.kind === 'field') { + return () => ord.push(initOrd); + } else { + return { + init() { + ord.push(initOrd); + } + } + } + } +} + + +var C = class { + @pushOrd(1, 3, 6) + @pushOrd(0, 4, 5) + + static accessor #element = ord.push(2) +; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(ord.length, 7); +ord.forEach(assert.sameValue); diff --git a/test/language/expressions/class/decorator/accessor/with-init/private/static/field-and-accessor-init-this.js b/test/language/expressions/class/decorator/accessor/with-init/private/static/field-and-accessor-init-this.js new file mode 100644 index 00000000000..719561e1248 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/with-init/private/static/field-and-accessor-init-this.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/accessors/with-init/private/static/cls-expr.template +/*--- +description: Field initializer `this` value is the instance or the class (private static with initializer acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +var C = class { + @dec + + static accessor #element = savedThisValues.push(this); +; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/expressions/class/decorator/accessor/with-init/public/instance/accessor-with-init-deco-returns-get.js b/test/language/expressions/class/decorator/accessor/with-init/public/instance/accessor-with-init-deco-returns-get.js new file mode 100644 index 00000000000..29d306e7e8e --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/with-init/public/instance/accessor-with-init-deco-returns-get.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-with-init-deco-returns-get.case +// - src/decorator/accessors/with-init/public/instance/cls-expr.template +/*--- +description: Accessor decorator can return a new getter (public accessor with initializer decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec({ get }) { + return { + get() { + assert.sameValue(get.call(this), 123); + return 456; + } + }; +} + + +var C = class { + @dec + + accessor element = 123 +; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/accessor/with-init/public/instance/accessor-with-init-deco-returns-init.js b/test/language/expressions/class/decorator/accessor/with-init/public/instance/accessor-with-init-deco-returns-init.js new file mode 100644 index 00000000000..38a058054d3 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/with-init/public/instance/accessor-with-init-deco-returns-init.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-with-init-deco-returns-init.case +// - src/decorator/accessors/with-init/public/instance/cls-expr.template +/*--- +description: Accessor decorator can return a new init that chains with default initializer (public accessor with initializer decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec({ get, set }) { + return { + init(value) { + assert.sameValue(value, 123); + return 456; + } + }; +} + + +var C = class { + @dec + + accessor element = 123 +; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 456); +classOrInstance.setElement(789); +assert.sameValue(classOrInstance.getElement(), 789); diff --git a/test/language/expressions/class/decorator/accessor/with-init/public/instance/accessor-with-init-deco-returns-set.js b/test/language/expressions/class/decorator/accessor/with-init/public/instance/accessor-with-init-deco-returns-set.js new file mode 100644 index 00000000000..41a31f7a894 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/with-init/public/instance/accessor-with-init-deco-returns-set.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-with-init-deco-returns-set.case +// - src/decorator/accessors/with-init/public/instance/cls-expr.template +/*--- +description: Accessor decorator can return a new setter when initializer is present (public accessor with initializer decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec({ set }) { + return { + set(value) { + assert.sameValue(value, 456); + set.call(this, 789); + } + }; +} + + +var C = class { + @dec + + accessor element = 123 +; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 123); +classOrInstance.setElement(456); +assert.sameValue(classOrInstance.getElement(), 789); diff --git a/test/language/expressions/class/decorator/accessor/with-init/public/instance/context-access-get.js b/test/language/expressions/class/decorator/accessor/with-init/public/instance/context-access-get.js new file mode 100644 index 00000000000..f53ee65a76f --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/with-init/public/instance/context-access-get.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-get.case +// - src/decorator/accessors/with-init/public/instance/cls-expr.template +/*--- +description: Context access `get` works on all gettable types of values (public accessor with initializer decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +var C = class { + @dec + + accessor element = 123 +; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), access.get(classOrInstance)); diff --git a/test/language/expressions/class/decorator/accessor/with-init/public/instance/context-access-set.js b/test/language/expressions/class/decorator/accessor/with-init/public/instance/context-access-set.js new file mode 100644 index 00000000000..fa825f10a10 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/with-init/public/instance/context-access-set.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-set.case +// - src/decorator/accessors/with-init/public/instance/cls-expr.template +/*--- +description: Context access `get` works on all gettable types of values (public accessor with initializer decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +var C = class { + @dec + + accessor element = 123 +; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/accessor/with-init/public/instance/decorator-order-application-field-and-accessor.js b/test/language/expressions/class/decorator/accessor/with-init/public/instance/decorator-order-application-field-and-accessor.js new file mode 100644 index 00000000000..a40222e62fe --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/with-init/public/instance/decorator-order-application-field-and-accessor.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-order-application-field-and-accessor.case +// - src/decorator/accessors/with-init/public/instance/cls-expr.template +/*--- +description: Order of decorator application for elements with initializers (public accessor with initializer decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +var ord = []; + +function pushOrd(applyOrd, initOrd, extraInitOrd) { + return (value, context) => { + ord.push(applyOrd); + context.addInitializer(() => ord.push(extraInitOrd)); + + if (context.kind === 'field') { + return () => ord.push(initOrd); + } else { + return { + init() { + ord.push(initOrd); + } + } + } + } +} + + +var C = class { + @pushOrd(1, 3, 6) + @pushOrd(0, 4, 5) + + accessor element = ord.push(2) +; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(ord.length, 7); +ord.forEach(assert.sameValue); diff --git a/test/language/expressions/class/decorator/accessor/with-init/public/instance/field-and-accessor-init-this.js b/test/language/expressions/class/decorator/accessor/with-init/public/instance/field-and-accessor-init-this.js new file mode 100644 index 00000000000..64408b46c14 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/with-init/public/instance/field-and-accessor-init-this.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/accessors/with-init/public/instance/cls-expr.template +/*--- +description: Field initializer `this` value is the instance or the class (public accessor with initializer decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +var C = class { + @dec + + accessor element = savedThisValues.push(this); +; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/expressions/class/decorator/accessor/with-init/public/static/accessor-with-init-deco-returns-get.js b/test/language/expressions/class/decorator/accessor/with-init/public/static/accessor-with-init-deco-returns-get.js new file mode 100644 index 00000000000..5a7b9ef63c9 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/with-init/public/static/accessor-with-init-deco-returns-get.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-with-init-deco-returns-get.case +// - src/decorator/accessors/with-init/public/static/cls-expr.template +/*--- +description: Accessor decorator can return a new getter (public static with initializer acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec({ get }) { + return { + get() { + assert.sameValue(get.call(this), 123); + return 456; + } + }; +} + + +var C = class { + @dec + + static accessor element = 123 +; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/accessor/with-init/public/static/accessor-with-init-deco-returns-init.js b/test/language/expressions/class/decorator/accessor/with-init/public/static/accessor-with-init-deco-returns-init.js new file mode 100644 index 00000000000..1944c1470f5 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/with-init/public/static/accessor-with-init-deco-returns-init.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-with-init-deco-returns-init.case +// - src/decorator/accessors/with-init/public/static/cls-expr.template +/*--- +description: Accessor decorator can return a new init that chains with default initializer (public static with initializer acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec({ get, set }) { + return { + init(value) { + assert.sameValue(value, 123); + return 456; + } + }; +} + + +var C = class { + @dec + + static accessor element = 123 +; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 456); +classOrInstance.setElement(789); +assert.sameValue(classOrInstance.getElement(), 789); diff --git a/test/language/expressions/class/decorator/accessor/with-init/public/static/accessor-with-init-deco-returns-set.js b/test/language/expressions/class/decorator/accessor/with-init/public/static/accessor-with-init-deco-returns-set.js new file mode 100644 index 00000000000..9b5afb997b3 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/with-init/public/static/accessor-with-init-deco-returns-set.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-with-init-deco-returns-set.case +// - src/decorator/accessors/with-init/public/static/cls-expr.template +/*--- +description: Accessor decorator can return a new setter when initializer is present (public static with initializer acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec({ set }) { + return { + set(value) { + assert.sameValue(value, 456); + set.call(this, 789); + } + }; +} + + +var C = class { + @dec + + static accessor element = 123 +; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 123); +classOrInstance.setElement(456); +assert.sameValue(classOrInstance.getElement(), 789); diff --git a/test/language/expressions/class/decorator/accessor/with-init/public/static/context-access-get.js b/test/language/expressions/class/decorator/accessor/with-init/public/static/context-access-get.js new file mode 100644 index 00000000000..cf85dd5292a --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/with-init/public/static/context-access-get.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-get.case +// - src/decorator/accessors/with-init/public/static/cls-expr.template +/*--- +description: Context access `get` works on all gettable types of values (public static with initializer acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +var C = class { + @dec + + static accessor element = 123 +; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), access.get(classOrInstance)); diff --git a/test/language/expressions/class/decorator/accessor/with-init/public/static/context-access-set.js b/test/language/expressions/class/decorator/accessor/with-init/public/static/context-access-set.js new file mode 100644 index 00000000000..29960b5ffc0 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/with-init/public/static/context-access-set.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-set.case +// - src/decorator/accessors/with-init/public/static/cls-expr.template +/*--- +description: Context access `get` works on all gettable types of values (public static with initializer acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +var C = class { + @dec + + static accessor element = 123 +; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/accessor/with-init/public/static/decorator-order-application-field-and-accessor.js b/test/language/expressions/class/decorator/accessor/with-init/public/static/decorator-order-application-field-and-accessor.js new file mode 100644 index 00000000000..5e71a4673ad --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/with-init/public/static/decorator-order-application-field-and-accessor.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-order-application-field-and-accessor.case +// - src/decorator/accessors/with-init/public/static/cls-expr.template +/*--- +description: Order of decorator application for elements with initializers (public static with initializer acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +var ord = []; + +function pushOrd(applyOrd, initOrd, extraInitOrd) { + return (value, context) => { + ord.push(applyOrd); + context.addInitializer(() => ord.push(extraInitOrd)); + + if (context.kind === 'field') { + return () => ord.push(initOrd); + } else { + return { + init() { + ord.push(initOrd); + } + } + } + } +} + + +var C = class { + @pushOrd(1, 3, 6) + @pushOrd(0, 4, 5) + + static accessor element = ord.push(2) +; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(ord.length, 7); +ord.forEach(assert.sameValue); diff --git a/test/language/expressions/class/decorator/accessor/with-init/public/static/field-and-accessor-init-this.js b/test/language/expressions/class/decorator/accessor/with-init/public/static/field-and-accessor-init-this.js new file mode 100644 index 00000000000..6bd09e450f8 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/with-init/public/static/field-and-accessor-init-this.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/accessors/with-init/public/static/cls-expr.template +/*--- +description: Field initializer `this` value is the instance or the class (public static with initializer acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +var C = class { + @dec + + static accessor element = savedThisValues.push(this); +; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/expressions/class/decorator/class/class-deco-returns-class.js b/test/language/expressions/class/decorator/class/class-deco-returns-class.js new file mode 100644 index 00000000000..8f929feee6e --- /dev/null +++ b/test/language/expressions/class/decorator/class/class-deco-returns-class.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/class-deco-returns-class.case +// - src/decorator/class/standard/cls-expr.template +/*--- +description: Class decorator can return a new class (decorator usage in a class expression) +esid: prod-FieldExpression +features: [decorators, class] +flags: [generated] +---*/ + + +var originalClass; +var newClass; + +function dec(C, context) { + originalClass = C; + newClass = class D { + static foo() { + return 123; + } + }; + + return newClass; +} + + +var C = @dec + class { + +} + +assert.sameValue(C, newClass); +assert(!(C instanceof originalClass), 'new class is not a subclass of old class'); +assert.sameValue(C.foo(), 123); + diff --git a/test/language/expressions/class/decorator/class/class-deco-returns-function.js b/test/language/expressions/class/decorator/class/class-deco-returns-function.js new file mode 100644 index 00000000000..05a09f4fca4 --- /dev/null +++ b/test/language/expressions/class/decorator/class/class-deco-returns-function.js @@ -0,0 +1,25 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/class-deco-returns-function.case +// - src/decorator/class/standard/cls-expr.template +/*--- +description: Class decorator can return a standard function (decorator usage in a class expression) +esid: prod-FieldExpression +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(C, context) { + return function() { + return 123; + }; +} + + +var C = @dec + class { + +} + +assert.sameValue(C(), 123); + diff --git a/test/language/expressions/class/decorator/class/class-deco-returns-proxy.js b/test/language/expressions/class/decorator/class/class-deco-returns-proxy.js new file mode 100644 index 00000000000..83e772953d3 --- /dev/null +++ b/test/language/expressions/class/decorator/class/class-deco-returns-proxy.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/class-deco-returns-proxy.case +// - src/decorator/class/standard/cls-expr.template +/*--- +description: Class decorator can return a Proxy (decorator usage in a class expression) +esid: prod-FieldExpression +features: [decorators, Proxy, class] +flags: [generated] +---*/ + + +var originalClass; +var subClass; + +function dec(C, context) { + originalClass = C; + + return new Proxy(C, { + construct() { + return 123; + } + }); +} + + +var C = @dec + class { + +} + +assert(C !== originalClass, 'values are not the same'); +assert(C instanceof originalClass, 'value is instance of class'); +assert.sameValue(new C(), 123); diff --git a/test/language/expressions/class/decorator/class/class-deco-returns-subclass.js b/test/language/expressions/class/decorator/class/class-deco-returns-subclass.js new file mode 100644 index 00000000000..8f5cccad2eb --- /dev/null +++ b/test/language/expressions/class/decorator/class/class-deco-returns-subclass.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/class-deco-returns-subclass.case +// - src/decorator/class/standard/cls-expr.template +/*--- +description: Class decorator can return a new class (decorator usage in a class expression) +esid: prod-FieldExpression +features: [decorators, class] +flags: [generated] +---*/ + + +var originalClass; +var subClass; + +function dec(C, context) { + originalClass = C; + subClass = class D extends C { + static foo() { + return 123; + } + }; + + return subClass; +} + + +var C = @dec + class { + +} + +var c = new C(); + +assert.sameValue(C, subClass); +assert(c instanceof originalClass, 'new class is subclass of old class'); +assert.sameValue(C.foo(), 123); diff --git a/test/language/expressions/class/decorator/class/context-kind-class.js b/test/language/expressions/class/decorator/class/context-kind-class.js new file mode 100644 index 00000000000..6b122652bf5 --- /dev/null +++ b/test/language/expressions/class/decorator/class/context-kind-class.js @@ -0,0 +1,21 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-class.case +// - src/decorator/class/standard/cls-expr.template +/*--- +description: Context kind is the string "class" when decorating a method (decorator usage in a class expression) +esid: prod-FieldExpression +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "class"); +} + + +var C = @dec class { + +} + + diff --git a/test/language/expressions/class/decorator/class/context-name-class.js b/test/language/expressions/class/decorator/class/context-name-class.js new file mode 100644 index 00000000000..29eb9ad27c2 --- /dev/null +++ b/test/language/expressions/class/decorator/class/context-name-class.js @@ -0,0 +1,21 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-class.case +// - src/decorator/class/standard/cls-expr.template +/*--- +description: Name of the class is correct on the context object (decorator usage in a class expression) +esid: prod-FieldExpression +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "C"); +} + + +var C = @dec class { + +} + + diff --git a/test/language/expressions/class/decorator/class/decorator-order-application-method-and-class.js b/test/language/expressions/class/decorator/class/decorator-order-application-method-and-class.js new file mode 100644 index 00000000000..ea1746747a9 --- /dev/null +++ b/test/language/expressions/class/decorator/class/decorator-order-application-method-and-class.js @@ -0,0 +1,29 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-order-application-method-and-class.case +// - src/decorator/class/standard/cls-expr.template +/*--- +description: Order of decorator application for elements without initializers (decorator usage in a class expression) +esid: prod-FieldExpression +features: [decorators, class] +flags: [generated] +---*/ + + +var ord = []; + +function pushOrd(applyOrd, extraInitOrd) { + return (value, context) => { + ord.push(applyOrd); + context.addInitializer(() => ord.push(extraInitOrd)); + } +} + + +var C = @pushOrd(1, 3) +@pushOrd(0, 2) + class { + +} + +assert.sameValue(ord.length, 4); +ord.forEach(assert.sameValue); diff --git a/test/language/expressions/class/decorator/class/decorator-order-phases-1-pre-definition.js b/test/language/expressions/class/decorator/class/decorator-order-phases-1-pre-definition.js new file mode 100644 index 00000000000..914f3615788 --- /dev/null +++ b/test/language/expressions/class/decorator/class/decorator-order-phases-1-pre-definition.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-order-phases-1-pre-definition.case +// - src/decorator/class/standard/cls-expr.template +/*--- +description: Class pre-definition evaluation phase order (decorator usage in a class expression) +esid: prod-FieldExpression +features: [decorators, class] +flags: [generated] +info: | + In the pre-definition phase, all expressions that are part of the class + definition itself are evaluated to get the final concrete values that are + needed to fully evaluate the class itself. This includes: + + - Dynamic element names + - Decorator expressions (e.g. `@foo()`, which calls a function and returns a + decorator) + + These are evaluated in lexical order from top to bottom. + +---*/ + + +var ord = []; + +// For dynamic element name evaluation order +function dynamicName(name, order) { + ord.push(order); + return name; +} + +function pushOrd(evalOrd) { + ord.push(evalOrd); + + return () => { + // do nothing + } +} + +ord.push(0); + + +var C = @pushOrd(1) + class { + @pushOrd(2) + [dynamicName('a', 3)]() {} + + @pushOrd(4) + #b() {} + + @pushOrd(5) + static [dynamicName('c', 6)]() {} + + @pushOrd(7) + static #d() {} + + @pushOrd(8) + [dynamicName('e', 9)] = 123; + + @pushOrd(10) + #f = 123; + +} + +ord.push(11); + +new C(); + +ord.push(12); + +assert.sameValue(ord.length, 13); +ord.forEach(assert.sameValue); diff --git a/test/language/expressions/class/decorator/class/decorator-order-phases-2-application.js b/test/language/expressions/class/decorator/class/decorator-order-phases-2-application.js new file mode 100644 index 00000000000..e9f5310bf4c --- /dev/null +++ b/test/language/expressions/class/decorator/class/decorator-order-phases-2-application.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-order-phases-2-application.case +// - src/decorator/class/standard/cls-expr.template +/*--- +description: Class definition decorator application order (decorator usage in a class expression) +esid: prod-FieldExpression +features: [decorators, class] +flags: [generated] +info: | + In the application phase, decorators are applied to each element in the + following order: + + 1. Static methods + 2. Instance methods + 3. Static fields + 4. Instance fields + 5. Class + + Within each group, decorators are applied to each _element_ in lexical order, + from top to bottom (note: This refers to ordering _between_ elements. Within a + single element definition, decorators are applied in reverse lexical order.) + As each method is defined, the method itself is assigned to the prototype or + class definition. + +---*/ + + +var ord = []; + +function pushOrd(applyOrd) { + return () => { + ord.push(applyOrd); + } +} + +ord.push(0); + + + +var C = @pushOrd(9) + + class { + @pushOrd(8) + a = 123; + + @pushOrd(4) + b() {} + + @pushOrd(1) + static accessor c = 123; + + @pushOrd(2) + static get d() {} + + + @pushOrd(5) + accessor e = 123; + + @pushOrd(6) + get f() {} + + @pushOrd(7) + static g = 123; + + @pushOrd(3) + static h() {} + + +} + +ord.push(10); + +new C(); + +ord.push(11); + +assert.sameValue(ord.length, 12); +ord.forEach(assert.sameValue); diff --git a/test/language/expressions/class/decorator/class/decorator-order-phases-3-init-static.js b/test/language/expressions/class/decorator/class/decorator-order-phases-3-init-static.js new file mode 100644 index 00000000000..7bb5b755847 --- /dev/null +++ b/test/language/expressions/class/decorator/class/decorator-order-phases-3-init-static.js @@ -0,0 +1,101 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-order-phases-3-init-static.case +// - src/decorator/class/standard/cls-expr.template +/*--- +description: Class definition static initialization order (decorator usage in a class expression) +esid: prod-FieldExpression +features: [decorators, class] +flags: [generated] +info: | + In the static initialization phase, the class definition is initialized in the + following order: + + 1. Static method extra-initializers are run, finalizing static method + definition. + 2. Static fields and blocks are evaluated and assigned in lexical order. For + each field, extra-initializers are run for that field immediately after + assignment. + 3. Class extra-initializers are run, finalizing the class definition. + + After this, the class is fully defined. + +---*/ + + +var ord = []; + +// For dynamic element name evaluation order +function dynamicName(name, order) { + ord.push(order); + return name; +} + +function pushOrd(initOrd, extraInitOrd) { + return (value, context) => { + if (context.kind === 'field') { + context.addInitializer(() => ord.push(extraInitOrd)); + + return () => ord.push(initOrd); + } else if (context.kind === 'accessor') { + context.addInitializer(() => ord.push(extraInitOrd)); + + return { + init() { + ord.push(initOrd); + } + } + } else { + context.addInitializer(() => ord.push(initOrd)); + } + } +} + +ord.push(0); + + + +var C = @pushOrd(12) + + class { + static { + ord.push(3); + } + + + @pushOrd(1) + static a() {} + + @pushOrd(5, 6) + static accessor b = ord.push(4); + + e = ord.push(14); + + + static { + ord.push(7); + } + + + accessor e = ord.push(15); + + @pushOrd(2) + static get c() {} + + @pushOrd(9, 10) + static d = ord.push(8); + + + static { + ord.push(11); + } + +} + +ord.push(13); + +new C(); + +ord.push(16); + +assert.sameValue(ord.length, 17); +ord.forEach(assert.sameValue); diff --git a/test/language/expressions/class/decorator/class/decorator-order-phases.js b/test/language/expressions/class/decorator/class/decorator-order-phases.js new file mode 100644 index 00000000000..ad3fff1a91e --- /dev/null +++ b/test/language/expressions/class/decorator/class/decorator-order-phases.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-order-phases.case +// - src/decorator/class/standard/cls-expr.template +/*--- +description: Order of decorators (decorator usage in a class expression) +esid: prod-FieldExpression +features: [decorators, class] +flags: [generated] +info: | + With decorators, definition and instantiation happens in 3 main observable + phases: + + 1. Pre-definition: + + Class key expressions and decorator expressions are evaluated, giving us + all the concrete values that are needed to fully evaluate the class + definition. + + 2. Decorator application and method assignment: + + Decorators are applied to each class element, and methods are + assigned to the class prototype (or class for static methods). Class + decorators are run after all other decorators, and the class identifier + is rebound to the final return value. + + 3. Static initialization: + + Static method extra initializers are run, then static blocks and fields + are initialized and assigned and field extra initializers are run. + Finally, class extra initializers are run. The class is now fully + defined. + + 4. Class instantiation: + + The last phases instantiation, when an instance is created. Instance + method and field extra initializers are run. + + This test compares the relative ordering of these phases, and other tests + check the ordering within each phase + +---*/ + + +var ord = []; + +function pushOrd(evalOrd, applyOrd, initOrd) { + ord.push(evalOrd); + + return (value, context) => { + ord.push(applyOrd); + + context.addInitializer(() => ord.push(initOrd)); + } +} + +ord.push(0); + + +var C = @pushOrd(1, 6, 7) + class { + @pushOrd(2, 4, 9) + a() {} + + @pushOrd(3, 5, 10) + b() {} + +} + +ord.push(8); + +new C(); + +assert.sameValue(ord.length, 11); +ord.forEach(assert.sameValue); diff --git a/test/language/expressions/class/decorator/class/error/class-deco-invalid-return-arrow.js b/test/language/expressions/class/decorator/class/error/class-deco-invalid-return-arrow.js new file mode 100644 index 00000000000..b62b4460116 --- /dev/null +++ b/test/language/expressions/class/decorator/class/error/class-deco-invalid-return-arrow.js @@ -0,0 +1,26 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/class-deco-invalid-return-arrow.case +// - src/decorator/class/error/cls-expr.template +/*--- +description: Class decorator cannot return non-newable function (arrow) (private method decorator evaluation error in class expression) +esid: prod-ClassExpression +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec() { + return () => {} +} + + +function evaluate() { + var C = class { + @dec + + #element() {} + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/expressions/class/decorator/class/error/class-deco-invalid-return-primitive.js b/test/language/expressions/class/decorator/class/error/class-deco-invalid-return-primitive.js new file mode 100644 index 00000000000..e329b506f9e --- /dev/null +++ b/test/language/expressions/class/decorator/class/error/class-deco-invalid-return-primitive.js @@ -0,0 +1,26 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/class-deco-invalid-return-primitive.case +// - src/decorator/class/error/cls-expr.template +/*--- +description: Class decorator cannot return a random non-newable value (private method decorator evaluation error in class expression) +esid: prod-ClassExpression +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec() { + return 123; +} + + +function evaluate() { + var C = class { + @dec + + #element() {} + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/expressions/class/decorator/class/with-super-class/decorator-order-phases-4-init-instance.js b/test/language/expressions/class/decorator/class/with-super-class/decorator-order-phases-4-init-instance.js new file mode 100644 index 00000000000..a221c0c70b7 --- /dev/null +++ b/test/language/expressions/class/decorator/class/with-super-class/decorator-order-phases-4-init-instance.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-order-phases-4-init-instance.case +// - src/decorator/class/with-super-class/cls-expr.template +/*--- +description: Class instance creation order (decorator usage in a class expression) +esid: prod-ClassExpression +features: [decorators, class] +flags: [generated] +info: | + Class instances are created in the following order: + + 1. The class constructor begins evaluating + 2. Super class is fully initialized (e.g. `super()` is called) + 3. Prototype method extra initializers are run, finalizing method definitions + 4. Instance field/accessors are assigned, and field/accessor extra + initializers run immediately after each field/accessor assignment. + +---*/ + + +var ord = []; + +// For dynamic element name evaluation order +function dynamicName(name, order) { + ord.push(order); + return name; +} + +function pushOrd(initOrd, extraInitOrd) { + return (value, context) => { + if (context.kind === 'field') { + context.addInitializer(() => ord.push(extraInitOrd)); + + return () => ord.push(initOrd); + } else if (context.kind === 'accessor') { + context.addInitializer(() => ord.push(extraInitOrd)); + + return { + init() { + ord.push(initOrd); + } + } + } else { + context.addInitializer(() => ord.push(initOrd)); + } + } +} + +ord.push(0); + + + +class B {} + +var C = class extends B { + constructor() { + ord.push(2); + super(); + ord.push(13); + } + + a = ord.push(5); + + @pushOrd(3) + b() {} + + @pushOrd(7, 8) + accessor c = ord.push(6); + + @pushOrd(4) + get d() {} + + accessor f = ord.push(9); + + @pushOrd(11, 12) + e = ord.push(10); + + +} + +ord.push(1); + +new C(); + +ord.push(14); + +assert.sameValue(ord.length, 15); +ord.forEach(assert.sameValue); diff --git a/test/language/expressions/class/decorator/field/error/private/instance/field-deco-invalid-return.js b/test/language/expressions/class/decorator/field/error/private/instance/field-deco-invalid-return.js new file mode 100644 index 00000000000..9e9b07440cb --- /dev/null +++ b/test/language/expressions/class/decorator/field/error/private/instance/field-deco-invalid-return.js @@ -0,0 +1,26 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-deco-invalid-return.case +// - src/decorator/fields/error/private/instance/cls-expr.template +/*--- +description: Decorator can't return an invalid value (private field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec(value) { + return 123; +} + + +function evaluate() { + var C = class { + @dec + + #element; + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/expressions/class/decorator/field/error/private/static/field-deco-invalid-return.js b/test/language/expressions/class/decorator/field/error/private/static/field-deco-invalid-return.js new file mode 100644 index 00000000000..05678818d5b --- /dev/null +++ b/test/language/expressions/class/decorator/field/error/private/static/field-deco-invalid-return.js @@ -0,0 +1,25 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-deco-invalid-return.case +// - src/decorator/fields/error/private/static/cls-expr.template +/*--- +description: Decorator can't return an invalid value (private static field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec(value) { + return 123; +} + + +function evaluate() { + var C = class { + @dec + + static #element; + } +} + +assert.throws(TypeError, evaluate); diff --git a/test/language/expressions/class/decorator/field/error/public/instance/field-deco-invalid-return.js b/test/language/expressions/class/decorator/field/error/public/instance/field-deco-invalid-return.js new file mode 100644 index 00000000000..a095b42f7fa --- /dev/null +++ b/test/language/expressions/class/decorator/field/error/public/instance/field-deco-invalid-return.js @@ -0,0 +1,26 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-deco-invalid-return.case +// - src/decorator/fields/error/public/instance/cls-expr.template +/*--- +description: Decorator can't return an invalid value (public field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec(value) { + return 123; +} + + +function evaluate() { + var C = class { + @dec + + element; + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/expressions/class/decorator/field/private/instance/context-access-set.js b/test/language/expressions/class/decorator/field/private/instance/context-access-set.js new file mode 100644 index 00000000000..d3dcbd4ccca --- /dev/null +++ b/test/language/expressions/class/decorator/field/private/instance/context-access-set.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-set.case +// - src/decorator/fields/standard/private/instance/cls-expr.template +/*--- +description: Context access `get` works on all gettable types of values (private field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +var C = class { + @dec + + #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/field/private/instance/context-kind-field.js b/test/language/expressions/class/decorator/field/private/instance/context-kind-field.js new file mode 100644 index 00000000000..5c88d185755 --- /dev/null +++ b/test/language/expressions/class/decorator/field/private/instance/context-kind-field.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-field.case +// - src/decorator/fields/standard/private/instance/cls-expr.template +/*--- +description: Context kind is the string "field" when decorating a field (private field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "field"); +} + + +var C = class { + @dec + #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/field/private/instance/context-name-private.js b/test/language/expressions/class/decorator/field/private/instance/context-name-private.js new file mode 100644 index 00000000000..87593f5ad5f --- /dev/null +++ b/test/language/expressions/class/decorator/field/private/instance/context-name-private.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-private.case +// - src/decorator/fields/standard/private/instance/cls-expr.template +/*--- +description: Context name is correct for all types of private elements (private field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "#element"); +} + + +var C = class { + @dec + #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/field/private/instance/context-private-false.js b/test/language/expressions/class/decorator/field/private/instance/context-private-false.js new file mode 100644 index 00000000000..df70bf4f59e --- /dev/null +++ b/test/language/expressions/class/decorator/field/private/instance/context-private-false.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-private-false.case +// - src/decorator/fields/standard/private/instance/cls-expr.template +/*--- +description: Context `private` is true for all types of private elements (private field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.private, true); +} + + +var C = class { + @dec + #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/field/private/instance/context-static-false.js b/test/language/expressions/class/decorator/field/private/instance/context-static-false.js new file mode 100644 index 00000000000..c722c58af65 --- /dev/null +++ b/test/language/expressions/class/decorator/field/private/instance/context-static-false.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-static-false.case +// - src/decorator/fields/standard/private/instance/cls-expr.template +/*--- +description: Context `static` is false for all types of instance elements (private field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.static, false); +} + + +var C = class { + @dec + #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/field/private/instance/field-and-accessor-init-this.js b/test/language/expressions/class/decorator/field/private/instance/field-and-accessor-init-this.js new file mode 100644 index 00000000000..75204cbaef2 --- /dev/null +++ b/test/language/expressions/class/decorator/field/private/instance/field-and-accessor-init-this.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/fields/standard/private/instance/cls-expr.template +/*--- +description: Field initializer `this` value is the instance or the class (private field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +var C = class { + @dec + + #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/expressions/class/decorator/field/private/instance/field-deco-returns-initializer.js b/test/language/expressions/class/decorator/field/private/instance/field-deco-returns-initializer.js new file mode 100644 index 00000000000..16d703cd612 --- /dev/null +++ b/test/language/expressions/class/decorator/field/private/instance/field-deco-returns-initializer.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-deco-returns-initializer.case +// - src/decorator/fields/standard/private/instance/cls-expr.template +/*--- +description: Decorator and initializer order (private field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec(value) { + return (init) => { + assert.sameValue(init, undefined); + return 123; + } +} + + +var C = class { + @dec + + #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 123); diff --git a/test/language/expressions/class/decorator/field/private/instance/field-deco-returns-undefined.js b/test/language/expressions/class/decorator/field/private/instance/field-deco-returns-undefined.js new file mode 100644 index 00000000000..04dc6fbef58 --- /dev/null +++ b/test/language/expressions/class/decorator/field/private/instance/field-deco-returns-undefined.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-deco-returns-undefined.case +// - src/decorator/fields/standard/private/instance/cls-expr.template +/*--- +description: Decorator can return undefined (private field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec(value) { + assert.sameValue(value, undefined); +} + + +var C = class { + @dec + + #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), undefined); diff --git a/test/language/expressions/class/decorator/field/private/static/context-access-set.js b/test/language/expressions/class/decorator/field/private/static/context-access-set.js new file mode 100644 index 00000000000..513b49361a6 --- /dev/null +++ b/test/language/expressions/class/decorator/field/private/static/context-access-set.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-set.case +// - src/decorator/fields/standard/private/static/cls-expr.template +/*--- +description: Context access `get` works on all gettable types of values (private static field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +var C = class { + @dec + + static #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/field/private/static/context-kind-field.js b/test/language/expressions/class/decorator/field/private/static/context-kind-field.js new file mode 100644 index 00000000000..b5cf9ae330a --- /dev/null +++ b/test/language/expressions/class/decorator/field/private/static/context-kind-field.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-field.case +// - src/decorator/fields/standard/private/static/cls-expr.template +/*--- +description: Context kind is the string "field" when decorating a field (private static field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "field"); +} + + +var C = class { + @dec + static #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/field/private/static/context-name-private.js b/test/language/expressions/class/decorator/field/private/static/context-name-private.js new file mode 100644 index 00000000000..1860db0a9f3 --- /dev/null +++ b/test/language/expressions/class/decorator/field/private/static/context-name-private.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-private.case +// - src/decorator/fields/standard/private/static/cls-expr.template +/*--- +description: Context name is correct for all types of private elements (private static field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "#element"); +} + + +var C = class { + @dec + static #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/field/private/static/context-private-false.js b/test/language/expressions/class/decorator/field/private/static/context-private-false.js new file mode 100644 index 00000000000..f938762cad1 --- /dev/null +++ b/test/language/expressions/class/decorator/field/private/static/context-private-false.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-private-false.case +// - src/decorator/fields/standard/private/static/cls-expr.template +/*--- +description: Context `private` is true for all types of private elements (private static field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.private, true); +} + + +var C = class { + @dec + static #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/field/private/static/context-static-true.js b/test/language/expressions/class/decorator/field/private/static/context-static-true.js new file mode 100644 index 00000000000..aed70884cd1 --- /dev/null +++ b/test/language/expressions/class/decorator/field/private/static/context-static-true.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-static-true.case +// - src/decorator/fields/standard/private/static/cls-expr.template +/*--- +description: Context `static` is false for all types of instance elements (private static field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.static, true); +} + + +var C = class { + @dec + static #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/field/private/static/field-and-accessor-init-this.js b/test/language/expressions/class/decorator/field/private/static/field-and-accessor-init-this.js new file mode 100644 index 00000000000..3fc70c9c346 --- /dev/null +++ b/test/language/expressions/class/decorator/field/private/static/field-and-accessor-init-this.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/fields/standard/private/static/cls-expr.template +/*--- +description: Field initializer `this` value is the instance or the class (private static field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +var C = class { + @dec + + static #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/expressions/class/decorator/field/private/static/field-deco-returns-initializer.js b/test/language/expressions/class/decorator/field/private/static/field-deco-returns-initializer.js new file mode 100644 index 00000000000..ad19129627f --- /dev/null +++ b/test/language/expressions/class/decorator/field/private/static/field-deco-returns-initializer.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-deco-returns-initializer.case +// - src/decorator/fields/standard/private/static/cls-expr.template +/*--- +description: Decorator and initializer order (private static field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec(value) { + return (init) => { + assert.sameValue(init, undefined); + return 123; + } +} + + +var C = class { + @dec + + static #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 123); diff --git a/test/language/expressions/class/decorator/field/private/static/field-deco-returns-undefined.js b/test/language/expressions/class/decorator/field/private/static/field-deco-returns-undefined.js new file mode 100644 index 00000000000..a5c566836b8 --- /dev/null +++ b/test/language/expressions/class/decorator/field/private/static/field-deco-returns-undefined.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-deco-returns-undefined.case +// - src/decorator/fields/standard/private/static/cls-expr.template +/*--- +description: Decorator can return undefined (private static field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec(value) { + assert.sameValue(value, undefined); +} + + +var C = class { + @dec + + static #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), undefined); diff --git a/test/language/expressions/class/decorator/field/public/instance/context-access-set.js b/test/language/expressions/class/decorator/field/public/instance/context-access-set.js new file mode 100644 index 00000000000..3e27ad18c95 --- /dev/null +++ b/test/language/expressions/class/decorator/field/public/instance/context-access-set.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-set.case +// - src/decorator/fields/standard/public/instance/cls-expr.template +/*--- +description: Context access `get` works on all gettable types of values (public field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +var C = class { + @dec + + element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/field/public/instance/context-kind-field.js b/test/language/expressions/class/decorator/field/public/instance/context-kind-field.js new file mode 100644 index 00000000000..1bd6b83b796 --- /dev/null +++ b/test/language/expressions/class/decorator/field/public/instance/context-kind-field.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-field.case +// - src/decorator/fields/standard/public/instance/cls-expr.template +/*--- +description: Context kind is the string "field" when decorating a field (public field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "field"); +} + + +var C = class { + @dec + element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/field/public/instance/context-name-public.js b/test/language/expressions/class/decorator/field/public/instance/context-name-public.js new file mode 100644 index 00000000000..fd71b20d9a7 --- /dev/null +++ b/test/language/expressions/class/decorator/field/public/instance/context-name-public.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-public.case +// - src/decorator/fields/standard/public/instance/cls-expr.template +/*--- +description: Context name is correct for all types of public elements (public field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "element"); +} + + +var C = class { + @dec + element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/field/public/instance/context-private-true.js b/test/language/expressions/class/decorator/field/public/instance/context-private-true.js new file mode 100644 index 00000000000..9c1717d84ba --- /dev/null +++ b/test/language/expressions/class/decorator/field/public/instance/context-private-true.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-private-true.case +// - src/decorator/fields/standard/public/instance/cls-expr.template +/*--- +description: Context `private` is false for all types of public elements (public field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.private, false); +} + + +var C = class { + @dec + element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/field/public/instance/context-static-false.js b/test/language/expressions/class/decorator/field/public/instance/context-static-false.js new file mode 100644 index 00000000000..3e8bb1ec667 --- /dev/null +++ b/test/language/expressions/class/decorator/field/public/instance/context-static-false.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-static-false.case +// - src/decorator/fields/standard/public/instance/cls-expr.template +/*--- +description: Context `static` is false for all types of instance elements (public field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.static, false); +} + + +var C = class { + @dec + element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/field/public/instance/field-and-accessor-init-this.js b/test/language/expressions/class/decorator/field/public/instance/field-and-accessor-init-this.js new file mode 100644 index 00000000000..60cbf47e9bc --- /dev/null +++ b/test/language/expressions/class/decorator/field/public/instance/field-and-accessor-init-this.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/fields/standard/public/instance/cls-expr.template +/*--- +description: Field initializer `this` value is the instance or the class (public field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +var C = class { + @dec + + element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/expressions/class/decorator/field/public/instance/field-deco-returns-initializer.js b/test/language/expressions/class/decorator/field/public/instance/field-deco-returns-initializer.js new file mode 100644 index 00000000000..3b711749dbe --- /dev/null +++ b/test/language/expressions/class/decorator/field/public/instance/field-deco-returns-initializer.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-deco-returns-initializer.case +// - src/decorator/fields/standard/public/instance/cls-expr.template +/*--- +description: Decorator and initializer order (public field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec(value) { + return (init) => { + assert.sameValue(init, undefined); + return 123; + } +} + + +var C = class { + @dec + + element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 123); diff --git a/test/language/expressions/class/decorator/field/public/instance/field-deco-returns-undefined.js b/test/language/expressions/class/decorator/field/public/instance/field-deco-returns-undefined.js new file mode 100644 index 00000000000..1227ff7fefb --- /dev/null +++ b/test/language/expressions/class/decorator/field/public/instance/field-deco-returns-undefined.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-deco-returns-undefined.case +// - src/decorator/fields/standard/public/instance/cls-expr.template +/*--- +description: Decorator can return undefined (public field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec(value) { + assert.sameValue(value, undefined); +} + + +var C = class { + @dec + + element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), undefined); diff --git a/test/language/expressions/class/decorator/field/public/static/context-access-set.js b/test/language/expressions/class/decorator/field/public/static/context-access-set.js new file mode 100644 index 00000000000..a044296137b --- /dev/null +++ b/test/language/expressions/class/decorator/field/public/static/context-access-set.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-set.case +// - src/decorator/fields/standard/public/static/cls-expr.template +/*--- +description: Context access `get` works on all gettable types of values (public static field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +var C = class { + @dec + + static element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/field/public/static/context-kind-field.js b/test/language/expressions/class/decorator/field/public/static/context-kind-field.js new file mode 100644 index 00000000000..c5b043f74a8 --- /dev/null +++ b/test/language/expressions/class/decorator/field/public/static/context-kind-field.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-field.case +// - src/decorator/fields/standard/public/static/cls-expr.template +/*--- +description: Context kind is the string "field" when decorating a field (public static field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "field"); +} + + +var C = class { + @dec + static element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/field/public/static/context-name-public.js b/test/language/expressions/class/decorator/field/public/static/context-name-public.js new file mode 100644 index 00000000000..cc071f38082 --- /dev/null +++ b/test/language/expressions/class/decorator/field/public/static/context-name-public.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-public.case +// - src/decorator/fields/standard/public/static/cls-expr.template +/*--- +description: Context name is correct for all types of public elements (public static field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "element"); +} + + +var C = class { + @dec + static element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/field/public/static/context-private-true.js b/test/language/expressions/class/decorator/field/public/static/context-private-true.js new file mode 100644 index 00000000000..be3bba489e4 --- /dev/null +++ b/test/language/expressions/class/decorator/field/public/static/context-private-true.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-private-true.case +// - src/decorator/fields/standard/public/static/cls-expr.template +/*--- +description: Context `private` is false for all types of public elements (public static field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.private, false); +} + + +var C = class { + @dec + static element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/field/public/static/context-static-true.js b/test/language/expressions/class/decorator/field/public/static/context-static-true.js new file mode 100644 index 00000000000..41f410b73ae --- /dev/null +++ b/test/language/expressions/class/decorator/field/public/static/context-static-true.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-static-true.case +// - src/decorator/fields/standard/public/static/cls-expr.template +/*--- +description: Context `static` is false for all types of instance elements (public static field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.static, true); +} + + +var C = class { + @dec + static element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/field/public/static/field-and-accessor-init-this.js b/test/language/expressions/class/decorator/field/public/static/field-and-accessor-init-this.js new file mode 100644 index 00000000000..b2ff9179f32 --- /dev/null +++ b/test/language/expressions/class/decorator/field/public/static/field-and-accessor-init-this.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/fields/standard/public/static/cls-expr.template +/*--- +description: Field initializer `this` value is the instance or the class (public static field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +var C = class { + @dec + + static element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/expressions/class/decorator/field/public/static/field-deco-invalid-return.js b/test/language/expressions/class/decorator/field/public/static/field-deco-invalid-return.js new file mode 100644 index 00000000000..ed323afc72f --- /dev/null +++ b/test/language/expressions/class/decorator/field/public/static/field-deco-invalid-return.js @@ -0,0 +1,25 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-deco-invalid-return.case +// - src/decorator/fields/error/public/static/cls-expr.template +/*--- +description: Decorator can't return an invalid value (public static field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec(value) { + return 123; +} + + +function evaluate() { + var C = class { + @dec + + static element; + } +} + +assert.throws(TypeError, evaluate); diff --git a/test/language/expressions/class/decorator/field/public/static/field-deco-returns-initializer.js b/test/language/expressions/class/decorator/field/public/static/field-deco-returns-initializer.js new file mode 100644 index 00000000000..02b941c2051 --- /dev/null +++ b/test/language/expressions/class/decorator/field/public/static/field-deco-returns-initializer.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-deco-returns-initializer.case +// - src/decorator/fields/standard/public/static/cls-expr.template +/*--- +description: Decorator and initializer order (public static field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec(value) { + return (init) => { + assert.sameValue(init, undefined); + return 123; + } +} + + +var C = class { + @dec + + static element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 123); diff --git a/test/language/expressions/class/decorator/field/public/static/field-deco-returns-undefined.js b/test/language/expressions/class/decorator/field/public/static/field-deco-returns-undefined.js new file mode 100644 index 00000000000..0f8e3432a62 --- /dev/null +++ b/test/language/expressions/class/decorator/field/public/static/field-deco-returns-undefined.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-deco-returns-undefined.case +// - src/decorator/fields/standard/public/static/cls-expr.template +/*--- +description: Decorator can return undefined (public static field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec(value) { + assert.sameValue(value, undefined); +} + + +var C = class { + @dec + + static element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), undefined); diff --git a/test/language/expressions/class/decorator/field/with-init/private/instance/context-access-get.js b/test/language/expressions/class/decorator/field/with-init/private/instance/context-access-get.js new file mode 100644 index 00000000000..bdf1083b626 --- /dev/null +++ b/test/language/expressions/class/decorator/field/with-init/private/instance/context-access-get.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-get.case +// - src/decorator/fields/with-init/private/instance/cls-expr.template +/*--- +description: Context access `get` works on all gettable types of values (private field with initializer decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +var C = class { + @dec + + #element = 123 +; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), access.get(classOrInstance)); diff --git a/test/language/expressions/class/decorator/field/with-init/private/instance/context-access-set.js b/test/language/expressions/class/decorator/field/with-init/private/instance/context-access-set.js new file mode 100644 index 00000000000..5d5e3d3e60b --- /dev/null +++ b/test/language/expressions/class/decorator/field/with-init/private/instance/context-access-set.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-set.case +// - src/decorator/fields/with-init/private/instance/cls-expr.template +/*--- +description: Context access `get` works on all gettable types of values (private field with initializer decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +var C = class { + @dec + + #element = 123 +; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/field/with-init/private/instance/decorator-order-application-field-and-accessor.js b/test/language/expressions/class/decorator/field/with-init/private/instance/decorator-order-application-field-and-accessor.js new file mode 100644 index 00000000000..02a80efa966 --- /dev/null +++ b/test/language/expressions/class/decorator/field/with-init/private/instance/decorator-order-application-field-and-accessor.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-order-application-field-and-accessor.case +// - src/decorator/fields/with-init/private/instance/cls-expr.template +/*--- +description: Order of decorator application for elements with initializers (private field with initializer decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +var ord = []; + +function pushOrd(applyOrd, initOrd, extraInitOrd) { + return (value, context) => { + ord.push(applyOrd); + context.addInitializer(() => ord.push(extraInitOrd)); + + if (context.kind === 'field') { + return () => ord.push(initOrd); + } else { + return { + init() { + ord.push(initOrd); + } + } + } + } +} + + +var C = class { + @pushOrd(1, 3, 6) + @pushOrd(0, 4, 5) + + #element = ord.push(2) +; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(ord.length, 7); +ord.forEach(assert.sameValue); diff --git a/test/language/expressions/class/decorator/field/with-init/private/instance/field-and-accessor-init-this.js b/test/language/expressions/class/decorator/field/with-init/private/instance/field-and-accessor-init-this.js new file mode 100644 index 00000000000..1abb84e0cc8 --- /dev/null +++ b/test/language/expressions/class/decorator/field/with-init/private/instance/field-and-accessor-init-this.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/fields/with-init/private/instance/cls-expr.template +/*--- +description: Field initializer `this` value is the instance or the class (private field with initializer decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +var C = class { + @dec + + #element = savedThisValues.push(this); +; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/expressions/class/decorator/field/with-init/private/instance/field-receives-undefined.js b/test/language/expressions/class/decorator/field/with-init/private/instance/field-receives-undefined.js new file mode 100644 index 00000000000..d5ee67b386e --- /dev/null +++ b/test/language/expressions/class/decorator/field/with-init/private/instance/field-receives-undefined.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-receives-undefined.case +// - src/decorator/fields/with-init/private/instance/cls-expr.template +/*--- +description: Value passed to field decorators is undefined (private field with initializer decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec(value) { + assert.sameValue(value, undefined); +} + + +var C = class { + @dec + #element = 123 +; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/field/with-init/private/instance/field-with-init-deco-returns-initializer.js b/test/language/expressions/class/decorator/field/with-init/private/instance/field-with-init-deco-returns-initializer.js new file mode 100644 index 00000000000..2dbfedf5e7d --- /dev/null +++ b/test/language/expressions/class/decorator/field/with-init/private/instance/field-with-init-deco-returns-initializer.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-with-init-deco-returns-initializer.case +// - src/decorator/fields/with-init/private/instance/cls-expr.template +/*--- +description: Decorator initializer is called with initial value during initialization (private field with initializer decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +info: | + InitializeFieldOrAccessor ( receiver, elementRecord ) + + ... + +---*/ + + +function dec(value) { + return (init) => { + assert.sameValue(init, 123); + return 456; + } +} + + +var C = class { + @dec + + #element = 123 +; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/field/with-init/private/instance/field-with-init-deco-returns-undefined.js b/test/language/expressions/class/decorator/field/with-init/private/instance/field-with-init-deco-returns-undefined.js new file mode 100644 index 00000000000..34e9c1f715d --- /dev/null +++ b/test/language/expressions/class/decorator/field/with-init/private/instance/field-with-init-deco-returns-undefined.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-with-init-deco-returns-undefined.case +// - src/decorator/fields/with-init/private/instance/cls-expr.template +/*--- +description: Decorator initializer is called with initial value during initialization (private field with initializer decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +info: | + InitializeFieldOrAccessor ( receiver, elementRecord ) + + ... + +---*/ + + +function dec(value) { + assert.sameValue(value, undefined); +} + + +var C = class { + @dec + + #element = 123 +; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 123); diff --git a/test/language/expressions/class/decorator/field/with-init/private/static/context-access-get.js b/test/language/expressions/class/decorator/field/with-init/private/static/context-access-get.js new file mode 100644 index 00000000000..77a8a913120 --- /dev/null +++ b/test/language/expressions/class/decorator/field/with-init/private/static/context-access-get.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-get.case +// - src/decorator/fields/with-init/private/static/cls-expr.template +/*--- +description: Context access `get` works on all gettable types of values (private static with initializer field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +var C = class { + @dec + + static #element = 123 +; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), access.get(classOrInstance)); diff --git a/test/language/expressions/class/decorator/field/with-init/private/static/context-access-set.js b/test/language/expressions/class/decorator/field/with-init/private/static/context-access-set.js new file mode 100644 index 00000000000..36ddc86fdbf --- /dev/null +++ b/test/language/expressions/class/decorator/field/with-init/private/static/context-access-set.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-set.case +// - src/decorator/fields/with-init/private/static/cls-expr.template +/*--- +description: Context access `get` works on all gettable types of values (private static with initializer field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +var C = class { + @dec + + static #element = 123 +; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/field/with-init/private/static/decorator-order-application-field-and-accessor.js b/test/language/expressions/class/decorator/field/with-init/private/static/decorator-order-application-field-and-accessor.js new file mode 100644 index 00000000000..c51b6f719d5 --- /dev/null +++ b/test/language/expressions/class/decorator/field/with-init/private/static/decorator-order-application-field-and-accessor.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-order-application-field-and-accessor.case +// - src/decorator/fields/with-init/private/static/cls-expr.template +/*--- +description: Order of decorator application for elements with initializers (private static with initializer field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +var ord = []; + +function pushOrd(applyOrd, initOrd, extraInitOrd) { + return (value, context) => { + ord.push(applyOrd); + context.addInitializer(() => ord.push(extraInitOrd)); + + if (context.kind === 'field') { + return () => ord.push(initOrd); + } else { + return { + init() { + ord.push(initOrd); + } + } + } + } +} + + +var C = class { + @pushOrd(1, 3, 6) + @pushOrd(0, 4, 5) + + static #element = ord.push(2) +; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(ord.length, 7); +ord.forEach(assert.sameValue); diff --git a/test/language/expressions/class/decorator/field/with-init/private/static/field-and-accessor-init-this.js b/test/language/expressions/class/decorator/field/with-init/private/static/field-and-accessor-init-this.js new file mode 100644 index 00000000000..9803e85aef7 --- /dev/null +++ b/test/language/expressions/class/decorator/field/with-init/private/static/field-and-accessor-init-this.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/fields/with-init/private/static/cls-expr.template +/*--- +description: Field initializer `this` value is the instance or the class (private static with initializer field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +var C = class { + @dec + + static #element = savedThisValues.push(this); +; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/expressions/class/decorator/field/with-init/private/static/field-receives-undefined.js b/test/language/expressions/class/decorator/field/with-init/private/static/field-receives-undefined.js new file mode 100644 index 00000000000..e1da78ace7e --- /dev/null +++ b/test/language/expressions/class/decorator/field/with-init/private/static/field-receives-undefined.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-receives-undefined.case +// - src/decorator/fields/with-init/private/static/cls-expr.template +/*--- +description: Value passed to field decorators is undefined (private static with initializer field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec(value) { + assert.sameValue(value, undefined); +} + + +var C = class { + @dec + static #element = 123 +; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/field/with-init/private/static/field-with-init-deco-returns-initializer.js b/test/language/expressions/class/decorator/field/with-init/private/static/field-with-init-deco-returns-initializer.js new file mode 100644 index 00000000000..7ceaf2e0aca --- /dev/null +++ b/test/language/expressions/class/decorator/field/with-init/private/static/field-with-init-deco-returns-initializer.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-with-init-deco-returns-initializer.case +// - src/decorator/fields/with-init/private/static/cls-expr.template +/*--- +description: Decorator initializer is called with initial value during initialization (private static with initializer field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +info: | + InitializeFieldOrAccessor ( receiver, elementRecord ) + + ... + +---*/ + + +function dec(value) { + return (init) => { + assert.sameValue(init, 123); + return 456; + } +} + + +var C = class { + @dec + + static #element = 123 +; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/field/with-init/private/static/field-with-init-deco-returns-undefined.js b/test/language/expressions/class/decorator/field/with-init/private/static/field-with-init-deco-returns-undefined.js new file mode 100644 index 00000000000..3c50eacc46a --- /dev/null +++ b/test/language/expressions/class/decorator/field/with-init/private/static/field-with-init-deco-returns-undefined.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-with-init-deco-returns-undefined.case +// - src/decorator/fields/with-init/private/static/cls-expr.template +/*--- +description: Decorator initializer is called with initial value during initialization (private static with initializer field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +info: | + InitializeFieldOrAccessor ( receiver, elementRecord ) + + ... + +---*/ + + +function dec(value) { + assert.sameValue(value, undefined); +} + + +var C = class { + @dec + + static #element = 123 +; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 123); diff --git a/test/language/expressions/class/decorator/field/with-init/public/instance/context-access-get.js b/test/language/expressions/class/decorator/field/with-init/public/instance/context-access-get.js new file mode 100644 index 00000000000..a5361720ccf --- /dev/null +++ b/test/language/expressions/class/decorator/field/with-init/public/instance/context-access-get.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-get.case +// - src/decorator/fields/with-init/public/instance/cls-expr.template +/*--- +description: Context access `get` works on all gettable types of values (public field with initializer decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +var C = class { + @dec + + element = 123 +; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), access.get(classOrInstance)); diff --git a/test/language/expressions/class/decorator/field/with-init/public/instance/context-access-set.js b/test/language/expressions/class/decorator/field/with-init/public/instance/context-access-set.js new file mode 100644 index 00000000000..c3956347751 --- /dev/null +++ b/test/language/expressions/class/decorator/field/with-init/public/instance/context-access-set.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-set.case +// - src/decorator/fields/with-init/public/instance/cls-expr.template +/*--- +description: Context access `get` works on all gettable types of values (public field with initializer decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +var C = class { + @dec + + element = 123 +; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/field/with-init/public/instance/decorator-order-application-field-and-accessor.js b/test/language/expressions/class/decorator/field/with-init/public/instance/decorator-order-application-field-and-accessor.js new file mode 100644 index 00000000000..eaee42e3f4b --- /dev/null +++ b/test/language/expressions/class/decorator/field/with-init/public/instance/decorator-order-application-field-and-accessor.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-order-application-field-and-accessor.case +// - src/decorator/fields/with-init/public/instance/cls-expr.template +/*--- +description: Order of decorator application for elements with initializers (public field with initializer decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +var ord = []; + +function pushOrd(applyOrd, initOrd, extraInitOrd) { + return (value, context) => { + ord.push(applyOrd); + context.addInitializer(() => ord.push(extraInitOrd)); + + if (context.kind === 'field') { + return () => ord.push(initOrd); + } else { + return { + init() { + ord.push(initOrd); + } + } + } + } +} + + +var C = class { + @pushOrd(1, 3, 6) + @pushOrd(0, 4, 5) + + element = ord.push(2) +; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(ord.length, 7); +ord.forEach(assert.sameValue); diff --git a/test/language/expressions/class/decorator/field/with-init/public/instance/field-and-accessor-init-this.js b/test/language/expressions/class/decorator/field/with-init/public/instance/field-and-accessor-init-this.js new file mode 100644 index 00000000000..bc60d1dcd52 --- /dev/null +++ b/test/language/expressions/class/decorator/field/with-init/public/instance/field-and-accessor-init-this.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/fields/with-init/public/instance/cls-expr.template +/*--- +description: Field initializer `this` value is the instance or the class (public field with initializer decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +var C = class { + @dec + + element = savedThisValues.push(this); +; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/expressions/class/decorator/field/with-init/public/instance/field-receives-undefined.js b/test/language/expressions/class/decorator/field/with-init/public/instance/field-receives-undefined.js new file mode 100644 index 00000000000..6dd057f5c53 --- /dev/null +++ b/test/language/expressions/class/decorator/field/with-init/public/instance/field-receives-undefined.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-receives-undefined.case +// - src/decorator/fields/with-init/public/instance/cls-expr.template +/*--- +description: Value passed to field decorators is undefined (public field with initializer decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec(value) { + assert.sameValue(value, undefined); +} + + +var C = class { + @dec + element = 123 +; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/field/with-init/public/instance/field-with-init-deco-returns-initializer.js b/test/language/expressions/class/decorator/field/with-init/public/instance/field-with-init-deco-returns-initializer.js new file mode 100644 index 00000000000..029f80e2dca --- /dev/null +++ b/test/language/expressions/class/decorator/field/with-init/public/instance/field-with-init-deco-returns-initializer.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-with-init-deco-returns-initializer.case +// - src/decorator/fields/with-init/public/instance/cls-expr.template +/*--- +description: Decorator initializer is called with initial value during initialization (public field with initializer decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +info: | + InitializeFieldOrAccessor ( receiver, elementRecord ) + + ... + +---*/ + + +function dec(value) { + return (init) => { + assert.sameValue(init, 123); + return 456; + } +} + + +var C = class { + @dec + + element = 123 +; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/field/with-init/public/instance/field-with-init-deco-returns-undefined.js b/test/language/expressions/class/decorator/field/with-init/public/instance/field-with-init-deco-returns-undefined.js new file mode 100644 index 00000000000..63af06546cb --- /dev/null +++ b/test/language/expressions/class/decorator/field/with-init/public/instance/field-with-init-deco-returns-undefined.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-with-init-deco-returns-undefined.case +// - src/decorator/fields/with-init/public/instance/cls-expr.template +/*--- +description: Decorator initializer is called with initial value during initialization (public field with initializer decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +info: | + InitializeFieldOrAccessor ( receiver, elementRecord ) + + ... + +---*/ + + +function dec(value) { + assert.sameValue(value, undefined); +} + + +var C = class { + @dec + + element = 123 +; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 123); diff --git a/test/language/expressions/class/decorator/field/with-init/public/static/context-access-get.js b/test/language/expressions/class/decorator/field/with-init/public/static/context-access-get.js new file mode 100644 index 00000000000..e23a2db9ef5 --- /dev/null +++ b/test/language/expressions/class/decorator/field/with-init/public/static/context-access-get.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-get.case +// - src/decorator/fields/with-init/public/static/cls-expr.template +/*--- +description: Context access `get` works on all gettable types of values (public static with initializer field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +var C = class { + @dec + + static element = 123 +; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), access.get(classOrInstance)); diff --git a/test/language/expressions/class/decorator/field/with-init/public/static/context-access-set.js b/test/language/expressions/class/decorator/field/with-init/public/static/context-access-set.js new file mode 100644 index 00000000000..1a9b395680a --- /dev/null +++ b/test/language/expressions/class/decorator/field/with-init/public/static/context-access-set.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-set.case +// - src/decorator/fields/with-init/public/static/cls-expr.template +/*--- +description: Context access `get` works on all gettable types of values (public static with initializer field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +var C = class { + @dec + + static element = 123 +; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/field/with-init/public/static/decorator-order-application-field-and-accessor.js b/test/language/expressions/class/decorator/field/with-init/public/static/decorator-order-application-field-and-accessor.js new file mode 100644 index 00000000000..8bbac833d05 --- /dev/null +++ b/test/language/expressions/class/decorator/field/with-init/public/static/decorator-order-application-field-and-accessor.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-order-application-field-and-accessor.case +// - src/decorator/fields/with-init/public/static/cls-expr.template +/*--- +description: Order of decorator application for elements with initializers (public static with initializer field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +var ord = []; + +function pushOrd(applyOrd, initOrd, extraInitOrd) { + return (value, context) => { + ord.push(applyOrd); + context.addInitializer(() => ord.push(extraInitOrd)); + + if (context.kind === 'field') { + return () => ord.push(initOrd); + } else { + return { + init() { + ord.push(initOrd); + } + } + } + } +} + + +var C = class { + @pushOrd(1, 3, 6) + @pushOrd(0, 4, 5) + + static element = ord.push(2) +; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(ord.length, 7); +ord.forEach(assert.sameValue); diff --git a/test/language/expressions/class/decorator/field/with-init/public/static/field-and-accessor-init-this.js b/test/language/expressions/class/decorator/field/with-init/public/static/field-and-accessor-init-this.js new file mode 100644 index 00000000000..93ae6f1e7a3 --- /dev/null +++ b/test/language/expressions/class/decorator/field/with-init/public/static/field-and-accessor-init-this.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/fields/with-init/public/static/cls-expr.template +/*--- +description: Field initializer `this` value is the instance or the class (public static with initializer field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +var C = class { + @dec + + static element = savedThisValues.push(this); +; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/expressions/class/decorator/field/with-init/public/static/field-receives-undefined.js b/test/language/expressions/class/decorator/field/with-init/public/static/field-receives-undefined.js new file mode 100644 index 00000000000..43f8355a350 --- /dev/null +++ b/test/language/expressions/class/decorator/field/with-init/public/static/field-receives-undefined.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-receives-undefined.case +// - src/decorator/fields/with-init/public/static/cls-expr.template +/*--- +description: Value passed to field decorators is undefined (public static with initializer field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec(value) { + assert.sameValue(value, undefined); +} + + +var C = class { + @dec + static element = 123 +; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/field/with-init/public/static/field-with-init-deco-returns-initializer.js b/test/language/expressions/class/decorator/field/with-init/public/static/field-with-init-deco-returns-initializer.js new file mode 100644 index 00000000000..651a6d7f0dd --- /dev/null +++ b/test/language/expressions/class/decorator/field/with-init/public/static/field-with-init-deco-returns-initializer.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-with-init-deco-returns-initializer.case +// - src/decorator/fields/with-init/public/static/cls-expr.template +/*--- +description: Decorator initializer is called with initial value during initialization (public static with initializer field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +info: | + InitializeFieldOrAccessor ( receiver, elementRecord ) + + ... + +---*/ + + +function dec(value) { + return (init) => { + assert.sameValue(init, 123); + return 456; + } +} + + +var C = class { + @dec + + static element = 123 +; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/field/with-init/public/static/field-with-init-deco-returns-undefined.js b/test/language/expressions/class/decorator/field/with-init/public/static/field-with-init-deco-returns-undefined.js new file mode 100644 index 00000000000..e98a92405ba --- /dev/null +++ b/test/language/expressions/class/decorator/field/with-init/public/static/field-with-init-deco-returns-undefined.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-with-init-deco-returns-undefined.case +// - src/decorator/fields/with-init/public/static/cls-expr.template +/*--- +description: Decorator initializer is called with initial value during initialization (public static with initializer field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +info: | + InitializeFieldOrAccessor ( receiver, elementRecord ) + + ... + +---*/ + + +function dec(value) { + assert.sameValue(value, undefined); +} + + +var C = class { + @dec + + static element = 123 +; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 123); diff --git a/test/language/expressions/class/decorator/getter/error/private/instance/getter-deco-returns-invalid.js b/test/language/expressions/class/decorator/getter/error/private/instance/getter-deco-returns-invalid.js new file mode 100644 index 00000000000..bb3cf25c5c4 --- /dev/null +++ b/test/language/expressions/class/decorator/getter/error/private/instance/getter-deco-returns-invalid.js @@ -0,0 +1,26 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/getter-deco-returns-invalid.case +// - src/decorator/getters/error/private/instance/cls-expr.template +/*--- +description: Decorator can't return an invalid value (private getter decorator evaluation error in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + return 123; +} + + +function evaluate() { + var C = class { + @dec + + get #element() {} + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/expressions/class/decorator/getter/error/private/static/context-kind-getter.js b/test/language/expressions/class/decorator/getter/error/private/static/context-kind-getter.js new file mode 100644 index 00000000000..c59e79e1ddc --- /dev/null +++ b/test/language/expressions/class/decorator/getter/error/private/static/context-kind-getter.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-getter.case +// - src/decorator/getters/standard/private/static/cls-expr.template +/*--- +description: Context kind is the string "method" when decorating a method (private static getter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "getter"); +} + + +var C = class { + static internalValue = 123; + + @dec + static get #element() { + return this.internalValue; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/getter/error/private/static/context-name-private.js b/test/language/expressions/class/decorator/getter/error/private/static/context-name-private.js new file mode 100644 index 00000000000..e30834a7551 --- /dev/null +++ b/test/language/expressions/class/decorator/getter/error/private/static/context-name-private.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-private.case +// - src/decorator/getters/standard/private/static/cls-expr.template +/*--- +description: Context name is correct for all types of private elements (private static getter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "#element"); +} + + +var C = class { + static internalValue = 123; + + @dec + static get #element() { + return this.internalValue; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/getter/error/private/static/context-private-false.js b/test/language/expressions/class/decorator/getter/error/private/static/context-private-false.js new file mode 100644 index 00000000000..c295ea26eec --- /dev/null +++ b/test/language/expressions/class/decorator/getter/error/private/static/context-private-false.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-private-false.case +// - src/decorator/getters/standard/private/static/cls-expr.template +/*--- +description: Context `private` is true for all types of private elements (private static getter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.private, true); +} + + +var C = class { + static internalValue = 123; + + @dec + static get #element() { + return this.internalValue; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/getter/error/private/static/context-static-true.js b/test/language/expressions/class/decorator/getter/error/private/static/context-static-true.js new file mode 100644 index 00000000000..8c28e759a21 --- /dev/null +++ b/test/language/expressions/class/decorator/getter/error/private/static/context-static-true.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-static-true.case +// - src/decorator/getters/standard/private/static/cls-expr.template +/*--- +description: Context `static` is false for all types of instance elements (private static getter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.static, true); +} + + +var C = class { + static internalValue = 123; + + @dec + static get #element() { + return this.internalValue; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/getter/error/private/static/getter-deco-returns-invalid.js b/test/language/expressions/class/decorator/getter/error/private/static/getter-deco-returns-invalid.js new file mode 100644 index 00000000000..4fbc6ec9119 --- /dev/null +++ b/test/language/expressions/class/decorator/getter/error/private/static/getter-deco-returns-invalid.js @@ -0,0 +1,25 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/getter-deco-returns-invalid.case +// - src/decorator/getters/error/private/static/cls-expr.template +/*--- +description: Decorator can't return an invalid value (private static getter decorator evaluation error in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + return 123; +} + + +function evaluate() { + var C = class { + @dec + + static get #element() {} + } +} + +assert.throws(TypeError, evaluate); diff --git a/test/language/expressions/class/decorator/getter/error/private/static/getter-deco-returns-replacement.js b/test/language/expressions/class/decorator/getter/error/private/static/getter-deco-returns-replacement.js new file mode 100644 index 00000000000..78c9eac74c1 --- /dev/null +++ b/test/language/expressions/class/decorator/getter/error/private/static/getter-deco-returns-replacement.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/getter-deco-returns-replacement.case +// - src/decorator/getters/standard/private/static/cls-expr.template +/*--- +description: Can replace a decorated getter with a new getter (private static getter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(value, context) { + + return function() { + assert.sameValue(value.call(this), 123); + + return 456; + }; +} + + +var C = class { + static internalValue = 123; + + @dec + + static get #element() { + return this.internalValue; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/getter/error/private/static/getter-deco-returns-undefined.js b/test/language/expressions/class/decorator/getter/error/private/static/getter-deco-returns-undefined.js new file mode 100644 index 00000000000..c85cfa53362 --- /dev/null +++ b/test/language/expressions/class/decorator/getter/error/private/static/getter-deco-returns-undefined.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/getter-deco-returns-undefined.case +// - src/decorator/getters/standard/private/static/cls-expr.template +/*--- +description: Decorator undefined return defaults to previous value (private static getter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec1(value, context) { + return function() { + assert.sameValue(value.call(this), 123); + + return 456; + }; +} + +function dec2() {} + + +var C = class { + static internalValue = 123; + + @dec2 @dec1 + + static get #element() { + return this.internalValue; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/getter/error/public/instance/getter-deco-returns-invalid.js b/test/language/expressions/class/decorator/getter/error/public/instance/getter-deco-returns-invalid.js new file mode 100644 index 00000000000..a38a06e5855 --- /dev/null +++ b/test/language/expressions/class/decorator/getter/error/public/instance/getter-deco-returns-invalid.js @@ -0,0 +1,26 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/getter-deco-returns-invalid.case +// - src/decorator/getters/error/public/instance/cls-expr.template +/*--- +description: Decorator can't return an invalid value (public getter decorator evaluation error in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + return 123; +} + + +function evaluate() { + var C = class { + @dec + + get element() {} + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/expressions/class/decorator/getter/error/public/static/getter-deco-returns-invalid.js b/test/language/expressions/class/decorator/getter/error/public/static/getter-deco-returns-invalid.js new file mode 100644 index 00000000000..133dad1c42c --- /dev/null +++ b/test/language/expressions/class/decorator/getter/error/public/static/getter-deco-returns-invalid.js @@ -0,0 +1,25 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/getter-deco-returns-invalid.case +// - src/decorator/getters/error/public/static/cls-expr.template +/*--- +description: Decorator can't return an invalid value (public static getter decorator evaluation error in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + return 123; +} + + +function evaluate() { + var C = class { + @dec + + static get element() {} + } +} + +assert.throws(TypeError, evaluate); diff --git a/test/language/expressions/class/decorator/getter/private/instance/context-kind-getter.js b/test/language/expressions/class/decorator/getter/private/instance/context-kind-getter.js new file mode 100644 index 00000000000..880c3e7b2e1 --- /dev/null +++ b/test/language/expressions/class/decorator/getter/private/instance/context-kind-getter.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-getter.case +// - src/decorator/getters/standard/private/instance/cls-expr.template +/*--- +description: Context kind is the string "method" when decorating a method (private getter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "getter"); +} + + +var C = class { + internalValue = 123; + + @dec + get #element() { + return this.internalValue; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/getter/private/instance/context-name-private.js b/test/language/expressions/class/decorator/getter/private/instance/context-name-private.js new file mode 100644 index 00000000000..09bf40159fe --- /dev/null +++ b/test/language/expressions/class/decorator/getter/private/instance/context-name-private.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-private.case +// - src/decorator/getters/standard/private/instance/cls-expr.template +/*--- +description: Context name is correct for all types of private elements (private getter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "#element"); +} + + +var C = class { + internalValue = 123; + + @dec + get #element() { + return this.internalValue; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/getter/private/instance/context-private-false.js b/test/language/expressions/class/decorator/getter/private/instance/context-private-false.js new file mode 100644 index 00000000000..a7cc88d74a3 --- /dev/null +++ b/test/language/expressions/class/decorator/getter/private/instance/context-private-false.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-private-false.case +// - src/decorator/getters/standard/private/instance/cls-expr.template +/*--- +description: Context `private` is true for all types of private elements (private getter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.private, true); +} + + +var C = class { + internalValue = 123; + + @dec + get #element() { + return this.internalValue; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/getter/private/instance/context-static-false.js b/test/language/expressions/class/decorator/getter/private/instance/context-static-false.js new file mode 100644 index 00000000000..fa273f85118 --- /dev/null +++ b/test/language/expressions/class/decorator/getter/private/instance/context-static-false.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-static-false.case +// - src/decorator/getters/standard/private/instance/cls-expr.template +/*--- +description: Context `static` is false for all types of instance elements (private getter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.static, false); +} + + +var C = class { + internalValue = 123; + + @dec + get #element() { + return this.internalValue; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/getter/private/instance/getter-deco-returns-replacement.js b/test/language/expressions/class/decorator/getter/private/instance/getter-deco-returns-replacement.js new file mode 100644 index 00000000000..4600fcde98c --- /dev/null +++ b/test/language/expressions/class/decorator/getter/private/instance/getter-deco-returns-replacement.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/getter-deco-returns-replacement.case +// - src/decorator/getters/standard/private/instance/cls-expr.template +/*--- +description: Can replace a decorated getter with a new getter (private getter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(value, context) { + + return function() { + assert.sameValue(value.call(this), 123); + + return 456; + }; +} + + +var C = class { + internalValue = 123; + + @dec + + get #element() { + return this.internalValue; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/getter/private/instance/getter-deco-returns-undefined.js b/test/language/expressions/class/decorator/getter/private/instance/getter-deco-returns-undefined.js new file mode 100644 index 00000000000..511079d9d2d --- /dev/null +++ b/test/language/expressions/class/decorator/getter/private/instance/getter-deco-returns-undefined.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/getter-deco-returns-undefined.case +// - src/decorator/getters/standard/private/instance/cls-expr.template +/*--- +description: Decorator undefined return defaults to previous value (private getter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec1(value, context) { + return function() { + assert.sameValue(value.call(this), 123); + + return 456; + }; +} + +function dec2() {} + + +var C = class { + internalValue = 123; + + @dec2 @dec1 + + get #element() { + return this.internalValue; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/getter/public/instance/context-kind-getter.js b/test/language/expressions/class/decorator/getter/public/instance/context-kind-getter.js new file mode 100644 index 00000000000..67b94e4c64c --- /dev/null +++ b/test/language/expressions/class/decorator/getter/public/instance/context-kind-getter.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-getter.case +// - src/decorator/getters/standard/public/instance/cls-expr.template +/*--- +description: Context kind is the string "method" when decorating a method (public getter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "getter"); +} + + +var C = class { + internalValue = 123; + + @dec + get element() { + return this.internalValue; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/getter/public/instance/context-name-public.js b/test/language/expressions/class/decorator/getter/public/instance/context-name-public.js new file mode 100644 index 00000000000..dbac07d509a --- /dev/null +++ b/test/language/expressions/class/decorator/getter/public/instance/context-name-public.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-public.case +// - src/decorator/getters/standard/public/instance/cls-expr.template +/*--- +description: Context name is correct for all types of public elements (public getter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "element"); +} + + +var C = class { + internalValue = 123; + + @dec + get element() { + return this.internalValue; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/getter/public/instance/context-private-true.js b/test/language/expressions/class/decorator/getter/public/instance/context-private-true.js new file mode 100644 index 00000000000..9628aecc705 --- /dev/null +++ b/test/language/expressions/class/decorator/getter/public/instance/context-private-true.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-private-true.case +// - src/decorator/getters/standard/public/instance/cls-expr.template +/*--- +description: Context `private` is false for all types of public elements (public getter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.private, false); +} + + +var C = class { + internalValue = 123; + + @dec + get element() { + return this.internalValue; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/getter/public/instance/context-static-false.js b/test/language/expressions/class/decorator/getter/public/instance/context-static-false.js new file mode 100644 index 00000000000..1f0724e8ad7 --- /dev/null +++ b/test/language/expressions/class/decorator/getter/public/instance/context-static-false.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-static-false.case +// - src/decorator/getters/standard/public/instance/cls-expr.template +/*--- +description: Context `static` is false for all types of instance elements (public getter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.static, false); +} + + +var C = class { + internalValue = 123; + + @dec + get element() { + return this.internalValue; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/getter/public/instance/getter-deco-returns-replacement.js b/test/language/expressions/class/decorator/getter/public/instance/getter-deco-returns-replacement.js new file mode 100644 index 00000000000..8939619204c --- /dev/null +++ b/test/language/expressions/class/decorator/getter/public/instance/getter-deco-returns-replacement.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/getter-deco-returns-replacement.case +// - src/decorator/getters/standard/public/instance/cls-expr.template +/*--- +description: Can replace a decorated getter with a new getter (public getter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(value, context) { + + return function() { + assert.sameValue(value.call(this), 123); + + return 456; + }; +} + + +var C = class { + internalValue = 123; + + @dec + + get element() { + return this.internalValue; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/getter/public/instance/getter-deco-returns-undefined.js b/test/language/expressions/class/decorator/getter/public/instance/getter-deco-returns-undefined.js new file mode 100644 index 00000000000..5fb028c2fab --- /dev/null +++ b/test/language/expressions/class/decorator/getter/public/instance/getter-deco-returns-undefined.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/getter-deco-returns-undefined.case +// - src/decorator/getters/standard/public/instance/cls-expr.template +/*--- +description: Decorator undefined return defaults to previous value (public getter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec1(value, context) { + return function() { + assert.sameValue(value.call(this), 123); + + return 456; + }; +} + +function dec2() {} + + +var C = class { + internalValue = 123; + + @dec2 @dec1 + + get element() { + return this.internalValue; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/getter/public/static/context-kind-getter.js b/test/language/expressions/class/decorator/getter/public/static/context-kind-getter.js new file mode 100644 index 00000000000..5e06f85e515 --- /dev/null +++ b/test/language/expressions/class/decorator/getter/public/static/context-kind-getter.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-getter.case +// - src/decorator/getters/standard/public/static/cls-expr.template +/*--- +description: Context kind is the string "method" when decorating a method (public static getter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "getter"); +} + + +var C = class { + static internalValue = 123; + + @dec + static get element() { + return this.internalValue; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/getter/public/static/context-name-public.js b/test/language/expressions/class/decorator/getter/public/static/context-name-public.js new file mode 100644 index 00000000000..20ee8873024 --- /dev/null +++ b/test/language/expressions/class/decorator/getter/public/static/context-name-public.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-public.case +// - src/decorator/getters/standard/public/static/cls-expr.template +/*--- +description: Context name is correct for all types of public elements (public static getter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "element"); +} + + +var C = class { + static internalValue = 123; + + @dec + static get element() { + return this.internalValue; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/getter/public/static/context-private-true.js b/test/language/expressions/class/decorator/getter/public/static/context-private-true.js new file mode 100644 index 00000000000..363ac22f4ea --- /dev/null +++ b/test/language/expressions/class/decorator/getter/public/static/context-private-true.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-private-true.case +// - src/decorator/getters/standard/public/static/cls-expr.template +/*--- +description: Context `private` is false for all types of public elements (public static getter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.private, false); +} + + +var C = class { + static internalValue = 123; + + @dec + static get element() { + return this.internalValue; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/getter/public/static/context-static-true.js b/test/language/expressions/class/decorator/getter/public/static/context-static-true.js new file mode 100644 index 00000000000..6a32f233fa8 --- /dev/null +++ b/test/language/expressions/class/decorator/getter/public/static/context-static-true.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-static-true.case +// - src/decorator/getters/standard/public/static/cls-expr.template +/*--- +description: Context `static` is false for all types of instance elements (public static getter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.static, true); +} + + +var C = class { + static internalValue = 123; + + @dec + static get element() { + return this.internalValue; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/getter/public/static/getter-deco-returns-replacement.js b/test/language/expressions/class/decorator/getter/public/static/getter-deco-returns-replacement.js new file mode 100644 index 00000000000..2b190022783 --- /dev/null +++ b/test/language/expressions/class/decorator/getter/public/static/getter-deco-returns-replacement.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/getter-deco-returns-replacement.case +// - src/decorator/getters/standard/public/static/cls-expr.template +/*--- +description: Can replace a decorated getter with a new getter (public static getter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(value, context) { + + return function() { + assert.sameValue(value.call(this), 123); + + return 456; + }; +} + + +var C = class { + static internalValue = 123; + + @dec + + static get element() { + return this.internalValue; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/getter/public/static/getter-deco-returns-undefined.js b/test/language/expressions/class/decorator/getter/public/static/getter-deco-returns-undefined.js new file mode 100644 index 00000000000..e4b02d3da1a --- /dev/null +++ b/test/language/expressions/class/decorator/getter/public/static/getter-deco-returns-undefined.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/getter-deco-returns-undefined.case +// - src/decorator/getters/standard/public/static/cls-expr.template +/*--- +description: Decorator undefined return defaults to previous value (public static getter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec1(value, context) { + return function() { + assert.sameValue(value.call(this), 123); + + return 456; + }; +} + +function dec2() {} + + +var C = class { + static internalValue = 123; + + @dec2 @dec1 + + static get element() { + return this.internalValue; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/method/async/private/instance/context-kind-method.js b/test/language/expressions/class/decorator/method/async/private/instance/context-kind-method.js new file mode 100644 index 00000000000..3bbcad6016c --- /dev/null +++ b/test/language/expressions/class/decorator/method/async/private/instance/context-kind-method.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-method.case +// - src/decorator/methods/async/private/instance/cls-expr.template +/*--- +description: Context kind is the string "method" when decorating a method (private method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "method"); +} + + +var C = class { + @dec + async #element() { + return 123; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/method/async/private/instance/method-async-deco-returns-replacement.js b/test/language/expressions/class/decorator/method/async/private/instance/method-async-deco-returns-replacement.js new file mode 100644 index 00000000000..7f57aa8592b --- /dev/null +++ b/test/language/expressions/class/decorator/method/async/private/instance/method-async-deco-returns-replacement.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-async-deco-returns-replacement.case +// - src/decorator/methods/async/private/instance/cls-expr.template +/*--- +description: Can replace a decorated method with a new method (private method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(value, context) { + assert(value() instanceof Promise); + + return () => 456; +} + + +var C = class { + @dec + + async #element() { + return 123; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/expressions/class/decorator/method/async/private/instance/method-async-deco-returns-undefined.js b/test/language/expressions/class/decorator/method/async/private/instance/method-async-deco-returns-undefined.js new file mode 100644 index 00000000000..9cf288f6496 --- /dev/null +++ b/test/language/expressions/class/decorator/method/async/private/instance/method-async-deco-returns-undefined.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-async-deco-returns-undefined.case +// - src/decorator/methods/async/private/instance/cls-expr.template +/*--- +description: Decorator undefined return defaults to previous value (private method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec1(value, context) { + assert(value() instanceof Promise); + + return () => 456; +} + +function dec2(value, context) { + assert.sameValue(value(), 456); +} + + +var C = class { + @dec2 @dec1 + + async #element() { + return 123; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/expressions/class/decorator/method/async/private/static/context-kind-method.js b/test/language/expressions/class/decorator/method/async/private/static/context-kind-method.js new file mode 100644 index 00000000000..c0e62410963 --- /dev/null +++ b/test/language/expressions/class/decorator/method/async/private/static/context-kind-method.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-method.case +// - src/decorator/methods/async/private/static/cls-expr.template +/*--- +description: Context kind is the string "method" when decorating a method (private static method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "method"); +} + + +var C = class { + @dec + static async #element() { + return 123; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/method/async/private/static/method-async-deco-returns-replacement.js b/test/language/expressions/class/decorator/method/async/private/static/method-async-deco-returns-replacement.js new file mode 100644 index 00000000000..4e5476d5e49 --- /dev/null +++ b/test/language/expressions/class/decorator/method/async/private/static/method-async-deco-returns-replacement.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-async-deco-returns-replacement.case +// - src/decorator/methods/async/private/static/cls-expr.template +/*--- +description: Can replace a decorated method with a new method (private static method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(value, context) { + assert(value() instanceof Promise); + + return () => 456; +} + + +var C = class { + @dec + + static async #element() { + return 123; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/expressions/class/decorator/method/async/private/static/method-async-deco-returns-undefined.js b/test/language/expressions/class/decorator/method/async/private/static/method-async-deco-returns-undefined.js new file mode 100644 index 00000000000..8b33427157e --- /dev/null +++ b/test/language/expressions/class/decorator/method/async/private/static/method-async-deco-returns-undefined.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-async-deco-returns-undefined.case +// - src/decorator/methods/async/private/static/cls-expr.template +/*--- +description: Decorator undefined return defaults to previous value (private static method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec1(value, context) { + assert(value() instanceof Promise); + + return () => 456; +} + +function dec2(value, context) { + assert.sameValue(value(), 456); +} + + +var C = class { + @dec2 @dec1 + + static async #element() { + return 123; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/expressions/class/decorator/method/async/public/instance/context-kind-method.js b/test/language/expressions/class/decorator/method/async/public/instance/context-kind-method.js new file mode 100644 index 00000000000..1293e404712 --- /dev/null +++ b/test/language/expressions/class/decorator/method/async/public/instance/context-kind-method.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-method.case +// - src/decorator/methods/async/public/instance/cls-expr.template +/*--- +description: Context kind is the string "method" when decorating a method (public method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "method"); +} + + +var C = class { + @dec + async element() { + return 123; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/method/async/public/instance/method-async-deco-returns-replacement.js b/test/language/expressions/class/decorator/method/async/public/instance/method-async-deco-returns-replacement.js new file mode 100644 index 00000000000..bf00d6a94b2 --- /dev/null +++ b/test/language/expressions/class/decorator/method/async/public/instance/method-async-deco-returns-replacement.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-async-deco-returns-replacement.case +// - src/decorator/methods/async/public/instance/cls-expr.template +/*--- +description: Can replace a decorated method with a new method (public method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(value, context) { + assert(value() instanceof Promise); + + return () => 456; +} + + +var C = class { + @dec + + async element() { + return 123; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/expressions/class/decorator/method/async/public/instance/method-async-deco-returns-undefined.js b/test/language/expressions/class/decorator/method/async/public/instance/method-async-deco-returns-undefined.js new file mode 100644 index 00000000000..2537bb86080 --- /dev/null +++ b/test/language/expressions/class/decorator/method/async/public/instance/method-async-deco-returns-undefined.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-async-deco-returns-undefined.case +// - src/decorator/methods/async/public/instance/cls-expr.template +/*--- +description: Decorator undefined return defaults to previous value (public method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec1(value, context) { + assert(value() instanceof Promise); + + return () => 456; +} + +function dec2(value, context) { + assert.sameValue(value(), 456); +} + + +var C = class { + @dec2 @dec1 + + async element() { + return 123; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/expressions/class/decorator/method/async/public/static/context-kind-method.js b/test/language/expressions/class/decorator/method/async/public/static/context-kind-method.js new file mode 100644 index 00000000000..f8ad912efca --- /dev/null +++ b/test/language/expressions/class/decorator/method/async/public/static/context-kind-method.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-method.case +// - src/decorator/methods/async/public/static/cls-expr.template +/*--- +description: Context kind is the string "method" when decorating a method (public static method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "method"); +} + + +var C = class { + @dec + static async element() { + return 123; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/method/async/public/static/method-async-deco-returns-replacement.js b/test/language/expressions/class/decorator/method/async/public/static/method-async-deco-returns-replacement.js new file mode 100644 index 00000000000..f1a71e5aa09 --- /dev/null +++ b/test/language/expressions/class/decorator/method/async/public/static/method-async-deco-returns-replacement.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-async-deco-returns-replacement.case +// - src/decorator/methods/async/public/static/cls-expr.template +/*--- +description: Can replace a decorated method with a new method (public static method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(value, context) { + assert(value() instanceof Promise); + + return () => 456; +} + + +var C = class { + @dec + + static async element() { + return 123; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/expressions/class/decorator/method/async/public/static/method-async-deco-returns-undefined.js b/test/language/expressions/class/decorator/method/async/public/static/method-async-deco-returns-undefined.js new file mode 100644 index 00000000000..f3fcdb40206 --- /dev/null +++ b/test/language/expressions/class/decorator/method/async/public/static/method-async-deco-returns-undefined.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-async-deco-returns-undefined.case +// - src/decorator/methods/async/public/static/cls-expr.template +/*--- +description: Decorator undefined return defaults to previous value (public static method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec1(value, context) { + assert(value() instanceof Promise); + + return () => 456; +} + +function dec2(value, context) { + assert.sameValue(value(), 456); +} + + +var C = class { + @dec2 @dec1 + + static async element() { + return 123; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/expressions/class/decorator/method/error/private/instance/method-deco-returns-invalid.js b/test/language/expressions/class/decorator/method/error/private/instance/method-deco-returns-invalid.js new file mode 100644 index 00000000000..5eb312e1ab8 --- /dev/null +++ b/test/language/expressions/class/decorator/method/error/private/instance/method-deco-returns-invalid.js @@ -0,0 +1,26 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-deco-returns-invalid.case +// - src/decorator/methods/error/private/instance/cls-expr.template +/*--- +description: Decorator can't return an invalid value (private method decorator evaluation error in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + return 123; +} + + +function evaluate() { + var C = class { + @dec + + #element() {} + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/expressions/class/decorator/method/error/private/static/method-deco-returns-invalid.js b/test/language/expressions/class/decorator/method/error/private/static/method-deco-returns-invalid.js new file mode 100644 index 00000000000..d43216a7ab4 --- /dev/null +++ b/test/language/expressions/class/decorator/method/error/private/static/method-deco-returns-invalid.js @@ -0,0 +1,25 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-deco-returns-invalid.case +// - src/decorator/methods/error/private/static/cls-expr.template +/*--- +description: Decorator can't return an invalid value (private static method decorator evaluation error in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + return 123; +} + + +function evaluate() { + var C = class { + @dec + + static #element() {} + } +} + +assert.throws(TypeError, evaluate); diff --git a/test/language/expressions/class/decorator/method/error/public/instance/method-deco-returns-invalid.js b/test/language/expressions/class/decorator/method/error/public/instance/method-deco-returns-invalid.js new file mode 100644 index 00000000000..1b8c73d29b7 --- /dev/null +++ b/test/language/expressions/class/decorator/method/error/public/instance/method-deco-returns-invalid.js @@ -0,0 +1,26 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-deco-returns-invalid.case +// - src/decorator/methods/error/public/instance/cls-expr.template +/*--- +description: Decorator can't return an invalid value (public method decorator evaluation error in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + return 123; +} + + +function evaluate() { + var C = class { + @dec + + element() {} + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/expressions/class/decorator/method/error/public/static/method-deco-returns-invalid.js b/test/language/expressions/class/decorator/method/error/public/static/method-deco-returns-invalid.js new file mode 100644 index 00000000000..dc8661d62aa --- /dev/null +++ b/test/language/expressions/class/decorator/method/error/public/static/method-deco-returns-invalid.js @@ -0,0 +1,25 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-deco-returns-invalid.case +// - src/decorator/methods/error/public/static/cls-expr.template +/*--- +description: Decorator can't return an invalid value (public static method decorator evaluation error in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + return 123; +} + + +function evaluate() { + var C = class { + @dec + + static element() {} + } +} + +assert.throws(TypeError, evaluate); diff --git a/test/language/expressions/class/decorator/method/private/instance/context-access-get.js b/test/language/expressions/class/decorator/method/private/instance/context-access-get.js new file mode 100644 index 00000000000..ce8174218fb --- /dev/null +++ b/test/language/expressions/class/decorator/method/private/instance/context-access-get.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-get.case +// - src/decorator/methods/standard/private/instance/cls-expr.template +/*--- +description: Context access `get` works on all gettable types of values (private method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +var C = class { + @dec + + #element() { + return 123; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), access.get(classOrInstance)); diff --git a/test/language/expressions/class/decorator/method/private/instance/context-kind-method.js b/test/language/expressions/class/decorator/method/private/instance/context-kind-method.js new file mode 100644 index 00000000000..61e484ed83c --- /dev/null +++ b/test/language/expressions/class/decorator/method/private/instance/context-kind-method.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-method.case +// - src/decorator/methods/standard/private/instance/cls-expr.template +/*--- +description: Context kind is the string "method" when decorating a method (private method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "method"); +} + + +var C = class { + @dec + #element() { + return 123; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/method/private/instance/context-name-private.js b/test/language/expressions/class/decorator/method/private/instance/context-name-private.js new file mode 100644 index 00000000000..2f3667cce5a --- /dev/null +++ b/test/language/expressions/class/decorator/method/private/instance/context-name-private.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-private.case +// - src/decorator/methods/standard/private/instance/cls-expr.template +/*--- +description: Context name is correct for all types of private elements (private method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "#element"); +} + + +var C = class { + @dec + #element() { + return 123; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/method/private/instance/context-private-false.js b/test/language/expressions/class/decorator/method/private/instance/context-private-false.js new file mode 100644 index 00000000000..e2fe8695895 --- /dev/null +++ b/test/language/expressions/class/decorator/method/private/instance/context-private-false.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-private-false.case +// - src/decorator/methods/standard/private/instance/cls-expr.template +/*--- +description: Context `private` is true for all types of private elements (private method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.private, true); +} + + +var C = class { + @dec + #element() { + return 123; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/method/private/instance/context-static-false.js b/test/language/expressions/class/decorator/method/private/instance/context-static-false.js new file mode 100644 index 00000000000..232d8e222a8 --- /dev/null +++ b/test/language/expressions/class/decorator/method/private/instance/context-static-false.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-static-false.case +// - src/decorator/methods/standard/private/instance/cls-expr.template +/*--- +description: Context `static` is false for all types of instance elements (private method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.static, false); +} + + +var C = class { + @dec + #element() { + return 123; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/method/private/instance/decorator-order-application-method-and-class.js b/test/language/expressions/class/decorator/method/private/instance/decorator-order-application-method-and-class.js new file mode 100644 index 00000000000..7aededddd5e --- /dev/null +++ b/test/language/expressions/class/decorator/method/private/instance/decorator-order-application-method-and-class.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-order-application-method-and-class.case +// - src/decorator/methods/standard/private/instance/cls-expr.template +/*--- +description: Order of decorator application for elements without initializers (private method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +var ord = []; + +function pushOrd(applyOrd, extraInitOrd) { + return (value, context) => { + ord.push(applyOrd); + context.addInitializer(() => ord.push(extraInitOrd)); + } +} + + +var C = class { + @pushOrd(1, 3) + @pushOrd(0, 2) + + #element() { + return 123; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + +assert.sameValue(ord.length, 4); +ord.forEach(assert.sameValue); diff --git a/test/language/expressions/class/decorator/method/private/instance/method-deco-returns-replacement.js b/test/language/expressions/class/decorator/method/private/instance/method-deco-returns-replacement.js new file mode 100644 index 00000000000..8865ea0730e --- /dev/null +++ b/test/language/expressions/class/decorator/method/private/instance/method-deco-returns-replacement.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-deco-returns-replacement.case +// - src/decorator/methods/standard/private/instance/cls-expr.template +/*--- +description: Can replace a decorated method with a new method (private method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(value, context) { + assert.sameValue(value(), 123); + + return () => 456; +} + + +var C = class { + @dec + + #element() { + return 123; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/expressions/class/decorator/method/private/instance/method-deco-returns-undefined.js b/test/language/expressions/class/decorator/method/private/instance/method-deco-returns-undefined.js new file mode 100644 index 00000000000..9c1362c0e85 --- /dev/null +++ b/test/language/expressions/class/decorator/method/private/instance/method-deco-returns-undefined.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-deco-returns-undefined.case +// - src/decorator/methods/standard/private/instance/cls-expr.template +/*--- +description: Decorator undefined return defaults to previous value (private method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec1(value, context) { + assert.sameValue(value(), 123); + + return () => 456; +} + +function dec2(value, context) { + assert.sameValue(value(), 456); +} + + +var C = class { + @dec2 @dec1 + + #element() { + return 123; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/expressions/class/decorator/method/private/instance/method-generator-deco-returns-replacement.js b/test/language/expressions/class/decorator/method/private/instance/method-generator-deco-returns-replacement.js new file mode 100644 index 00000000000..8c9d49e6e1d --- /dev/null +++ b/test/language/expressions/class/decorator/method/private/instance/method-generator-deco-returns-replacement.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-generator-deco-returns-replacement.case +// - src/decorator/methods/generator/private/instance/cls-expr.template +/*--- +description: Can replace a decorated method with a new method (private method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(value, context) { + assert(value() instanceof Iterator, 'value is iterator'); + + return () => 456; +} + + +var C = class { + @dec + + * #element() { + return 123; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/expressions/class/decorator/method/private/instance/method-generator-deco-returns-undefined.js b/test/language/expressions/class/decorator/method/private/instance/method-generator-deco-returns-undefined.js new file mode 100644 index 00000000000..9c5293c1158 --- /dev/null +++ b/test/language/expressions/class/decorator/method/private/instance/method-generator-deco-returns-undefined.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-generator-deco-returns-undefined.case +// - src/decorator/methods/generator/private/instance/cls-expr.template +/*--- +description: Decorator undefined return defaults to previous value (private method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec1(value, context) { + assert(value() instanceof Iterator, 'value is iterator'); + + return () => 456; +} + +function dec2(value, context) { + assert.sameValue(value(), 456); +} + + +var C = class { + @dec2 @dec1 + + * #element() { + return 123; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/expressions/class/decorator/method/private/static/context-access-get.js b/test/language/expressions/class/decorator/method/private/static/context-access-get.js new file mode 100644 index 00000000000..824412ccf1e --- /dev/null +++ b/test/language/expressions/class/decorator/method/private/static/context-access-get.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-get.case +// - src/decorator/methods/standard/private/static/cls-expr.template +/*--- +description: Context access `get` works on all gettable types of values (private static method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +var C = class { + @dec + + static #element() { + return 123; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), access.get(classOrInstance)); diff --git a/test/language/expressions/class/decorator/method/private/static/context-kind-method.js b/test/language/expressions/class/decorator/method/private/static/context-kind-method.js new file mode 100644 index 00000000000..6ed84380275 --- /dev/null +++ b/test/language/expressions/class/decorator/method/private/static/context-kind-method.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-method.case +// - src/decorator/methods/standard/private/static/cls-expr.template +/*--- +description: Context kind is the string "method" when decorating a method (private static method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "method"); +} + + +var C = class { + @dec + static #element() { + return 123; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/method/private/static/context-name-private.js b/test/language/expressions/class/decorator/method/private/static/context-name-private.js new file mode 100644 index 00000000000..a87242f239e --- /dev/null +++ b/test/language/expressions/class/decorator/method/private/static/context-name-private.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-private.case +// - src/decorator/methods/standard/private/static/cls-expr.template +/*--- +description: Context name is correct for all types of private elements (private static method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "#element"); +} + + +var C = class { + @dec + static #element() { + return 123; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/method/private/static/context-private-false.js b/test/language/expressions/class/decorator/method/private/static/context-private-false.js new file mode 100644 index 00000000000..2febade86f3 --- /dev/null +++ b/test/language/expressions/class/decorator/method/private/static/context-private-false.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-private-false.case +// - src/decorator/methods/standard/private/static/cls-expr.template +/*--- +description: Context `private` is true for all types of private elements (private static method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.private, true); +} + + +var C = class { + @dec + static #element() { + return 123; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/method/private/static/context-static-true.js b/test/language/expressions/class/decorator/method/private/static/context-static-true.js new file mode 100644 index 00000000000..951fadc0a40 --- /dev/null +++ b/test/language/expressions/class/decorator/method/private/static/context-static-true.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-static-true.case +// - src/decorator/methods/standard/private/static/cls-expr.template +/*--- +description: Context `static` is false for all types of instance elements (private static method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.static, true); +} + + +var C = class { + @dec + static #element() { + return 123; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/method/private/static/decorator-order-application-method-and-class.js b/test/language/expressions/class/decorator/method/private/static/decorator-order-application-method-and-class.js new file mode 100644 index 00000000000..5de06818912 --- /dev/null +++ b/test/language/expressions/class/decorator/method/private/static/decorator-order-application-method-and-class.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-order-application-method-and-class.case +// - src/decorator/methods/standard/private/static/cls-expr.template +/*--- +description: Order of decorator application for elements without initializers (private static method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +var ord = []; + +function pushOrd(applyOrd, extraInitOrd) { + return (value, context) => { + ord.push(applyOrd); + context.addInitializer(() => ord.push(extraInitOrd)); + } +} + + +var C = class { + @pushOrd(1, 3) + @pushOrd(0, 2) + + static #element() { + return 123; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + +assert.sameValue(ord.length, 4); +ord.forEach(assert.sameValue); diff --git a/test/language/expressions/class/decorator/method/private/static/method-deco-returns-replacement.js b/test/language/expressions/class/decorator/method/private/static/method-deco-returns-replacement.js new file mode 100644 index 00000000000..5e5a536ccf2 --- /dev/null +++ b/test/language/expressions/class/decorator/method/private/static/method-deco-returns-replacement.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-deco-returns-replacement.case +// - src/decorator/methods/standard/private/static/cls-expr.template +/*--- +description: Can replace a decorated method with a new method (private static method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(value, context) { + assert.sameValue(value(), 123); + + return () => 456; +} + + +var C = class { + @dec + + static #element() { + return 123; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/expressions/class/decorator/method/private/static/method-deco-returns-undefined.js b/test/language/expressions/class/decorator/method/private/static/method-deco-returns-undefined.js new file mode 100644 index 00000000000..60783854522 --- /dev/null +++ b/test/language/expressions/class/decorator/method/private/static/method-deco-returns-undefined.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-deco-returns-undefined.case +// - src/decorator/methods/standard/private/static/cls-expr.template +/*--- +description: Decorator undefined return defaults to previous value (private static method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec1(value, context) { + assert.sameValue(value(), 123); + + return () => 456; +} + +function dec2(value, context) { + assert.sameValue(value(), 456); +} + + +var C = class { + @dec2 @dec1 + + static #element() { + return 123; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/expressions/class/decorator/method/private/static/method-generator-deco-returns-replacement.js b/test/language/expressions/class/decorator/method/private/static/method-generator-deco-returns-replacement.js new file mode 100644 index 00000000000..eae51900101 --- /dev/null +++ b/test/language/expressions/class/decorator/method/private/static/method-generator-deco-returns-replacement.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-generator-deco-returns-replacement.case +// - src/decorator/methods/generator/private/static/cls-expr.template +/*--- +description: Can replace a decorated method with a new method (private static method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(value, context) { + assert(value() instanceof Iterator, 'value is iterator'); + + return () => 456; +} + + +var C = class { + @dec + + static * #element() { + return 123; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/expressions/class/decorator/method/private/static/method-generator-deco-returns-undefined.js b/test/language/expressions/class/decorator/method/private/static/method-generator-deco-returns-undefined.js new file mode 100644 index 00000000000..eeb10bb2925 --- /dev/null +++ b/test/language/expressions/class/decorator/method/private/static/method-generator-deco-returns-undefined.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-generator-deco-returns-undefined.case +// - src/decorator/methods/generator/private/static/cls-expr.template +/*--- +description: Decorator undefined return defaults to previous value (private static method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec1(value, context) { + assert(value() instanceof Iterator, 'value is iterator'); + + return () => 456; +} + +function dec2(value, context) { + assert.sameValue(value(), 456); +} + + +var C = class { + @dec2 @dec1 + + static * #element() { + return 123; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/expressions/class/decorator/method/public/instance/context-access-get.js b/test/language/expressions/class/decorator/method/public/instance/context-access-get.js new file mode 100644 index 00000000000..12e4ab7110f --- /dev/null +++ b/test/language/expressions/class/decorator/method/public/instance/context-access-get.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-get.case +// - src/decorator/methods/standard/public/instance/cls-expr.template +/*--- +description: Context access `get` works on all gettable types of values (public method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +var C = class { + @dec + + element() { + return 123; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), access.get(classOrInstance)); diff --git a/test/language/expressions/class/decorator/method/public/instance/context-kind-method.js b/test/language/expressions/class/decorator/method/public/instance/context-kind-method.js new file mode 100644 index 00000000000..5d19e7bcfd3 --- /dev/null +++ b/test/language/expressions/class/decorator/method/public/instance/context-kind-method.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-method.case +// - src/decorator/methods/standard/public/instance/cls-expr.template +/*--- +description: Context kind is the string "method" when decorating a method (public method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "method"); +} + + +var C = class { + @dec + element() { + return 123; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/method/public/instance/context-name-public.js b/test/language/expressions/class/decorator/method/public/instance/context-name-public.js new file mode 100644 index 00000000000..4db5f7d5ed1 --- /dev/null +++ b/test/language/expressions/class/decorator/method/public/instance/context-name-public.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-public.case +// - src/decorator/methods/standard/public/instance/cls-expr.template +/*--- +description: Context name is correct for all types of public elements (public method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "element"); +} + + +var C = class { + @dec + element() { + return 123; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/method/public/instance/context-private-true.js b/test/language/expressions/class/decorator/method/public/instance/context-private-true.js new file mode 100644 index 00000000000..85d509620af --- /dev/null +++ b/test/language/expressions/class/decorator/method/public/instance/context-private-true.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-private-true.case +// - src/decorator/methods/standard/public/instance/cls-expr.template +/*--- +description: Context `private` is false for all types of public elements (public method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.private, false); +} + + +var C = class { + @dec + element() { + return 123; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/method/public/instance/context-static-false.js b/test/language/expressions/class/decorator/method/public/instance/context-static-false.js new file mode 100644 index 00000000000..bed2751a426 --- /dev/null +++ b/test/language/expressions/class/decorator/method/public/instance/context-static-false.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-static-false.case +// - src/decorator/methods/standard/public/instance/cls-expr.template +/*--- +description: Context `static` is false for all types of instance elements (public method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.static, false); +} + + +var C = class { + @dec + element() { + return 123; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/method/public/instance/decorator-order-application-method-and-class.js b/test/language/expressions/class/decorator/method/public/instance/decorator-order-application-method-and-class.js new file mode 100644 index 00000000000..f21bd35ecb4 --- /dev/null +++ b/test/language/expressions/class/decorator/method/public/instance/decorator-order-application-method-and-class.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-order-application-method-and-class.case +// - src/decorator/methods/standard/public/instance/cls-expr.template +/*--- +description: Order of decorator application for elements without initializers (public method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +var ord = []; + +function pushOrd(applyOrd, extraInitOrd) { + return (value, context) => { + ord.push(applyOrd); + context.addInitializer(() => ord.push(extraInitOrd)); + } +} + + +var C = class { + @pushOrd(1, 3) + @pushOrd(0, 2) + + element() { + return 123; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + +assert.sameValue(ord.length, 4); +ord.forEach(assert.sameValue); diff --git a/test/language/expressions/class/decorator/method/public/instance/method-deco-returns-replacement.js b/test/language/expressions/class/decorator/method/public/instance/method-deco-returns-replacement.js new file mode 100644 index 00000000000..a945ce7183b --- /dev/null +++ b/test/language/expressions/class/decorator/method/public/instance/method-deco-returns-replacement.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-deco-returns-replacement.case +// - src/decorator/methods/standard/public/instance/cls-expr.template +/*--- +description: Can replace a decorated method with a new method (public method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(value, context) { + assert.sameValue(value(), 123); + + return () => 456; +} + + +var C = class { + @dec + + element() { + return 123; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/expressions/class/decorator/method/public/instance/method-deco-returns-undefined.js b/test/language/expressions/class/decorator/method/public/instance/method-deco-returns-undefined.js new file mode 100644 index 00000000000..e46fb704e2f --- /dev/null +++ b/test/language/expressions/class/decorator/method/public/instance/method-deco-returns-undefined.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-deco-returns-undefined.case +// - src/decorator/methods/standard/public/instance/cls-expr.template +/*--- +description: Decorator undefined return defaults to previous value (public method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec1(value, context) { + assert.sameValue(value(), 123); + + return () => 456; +} + +function dec2(value, context) { + assert.sameValue(value(), 456); +} + + +var C = class { + @dec2 @dec1 + + element() { + return 123; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/expressions/class/decorator/method/public/instance/method-generator-deco-returns-replacement.js b/test/language/expressions/class/decorator/method/public/instance/method-generator-deco-returns-replacement.js new file mode 100644 index 00000000000..d319aa1703b --- /dev/null +++ b/test/language/expressions/class/decorator/method/public/instance/method-generator-deco-returns-replacement.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-generator-deco-returns-replacement.case +// - src/decorator/methods/generator/public/instance/cls-expr.template +/*--- +description: Can replace a decorated method with a new method (public method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(value, context) { + assert(value() instanceof Iterator, 'value is iterator'); + + return () => 456; +} + + +var C = class { + @dec + + * element() { + return 123; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/expressions/class/decorator/method/public/instance/method-generator-deco-returns-undefined.js b/test/language/expressions/class/decorator/method/public/instance/method-generator-deco-returns-undefined.js new file mode 100644 index 00000000000..7b861e3668e --- /dev/null +++ b/test/language/expressions/class/decorator/method/public/instance/method-generator-deco-returns-undefined.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-generator-deco-returns-undefined.case +// - src/decorator/methods/generator/public/instance/cls-expr.template +/*--- +description: Decorator undefined return defaults to previous value (public method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec1(value, context) { + assert(value() instanceof Iterator, 'value is iterator'); + + return () => 456; +} + +function dec2(value, context) { + assert.sameValue(value(), 456); +} + + +var C = class { + @dec2 @dec1 + + * element() { + return 123; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/expressions/class/decorator/method/public/static/context-access-get.js b/test/language/expressions/class/decorator/method/public/static/context-access-get.js new file mode 100644 index 00000000000..01b13e694ab --- /dev/null +++ b/test/language/expressions/class/decorator/method/public/static/context-access-get.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-get.case +// - src/decorator/methods/standard/public/static/cls-expr.template +/*--- +description: Context access `get` works on all gettable types of values (public static method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +var C = class { + @dec + + static element() { + return 123; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), access.get(classOrInstance)); diff --git a/test/language/expressions/class/decorator/method/public/static/context-kind-method.js b/test/language/expressions/class/decorator/method/public/static/context-kind-method.js new file mode 100644 index 00000000000..87c50929c5a --- /dev/null +++ b/test/language/expressions/class/decorator/method/public/static/context-kind-method.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-method.case +// - src/decorator/methods/standard/public/static/cls-expr.template +/*--- +description: Context kind is the string "method" when decorating a method (public static method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "method"); +} + + +var C = class { + @dec + static element() { + return 123; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/method/public/static/context-name-public.js b/test/language/expressions/class/decorator/method/public/static/context-name-public.js new file mode 100644 index 00000000000..3ebb9695588 --- /dev/null +++ b/test/language/expressions/class/decorator/method/public/static/context-name-public.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-public.case +// - src/decorator/methods/standard/public/static/cls-expr.template +/*--- +description: Context name is correct for all types of public elements (public static method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "element"); +} + + +var C = class { + @dec + static element() { + return 123; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/method/public/static/context-private-true.js b/test/language/expressions/class/decorator/method/public/static/context-private-true.js new file mode 100644 index 00000000000..6e919fcd4c9 --- /dev/null +++ b/test/language/expressions/class/decorator/method/public/static/context-private-true.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-private-true.case +// - src/decorator/methods/standard/public/static/cls-expr.template +/*--- +description: Context `private` is false for all types of public elements (public static method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.private, false); +} + + +var C = class { + @dec + static element() { + return 123; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/method/public/static/context-static-true.js b/test/language/expressions/class/decorator/method/public/static/context-static-true.js new file mode 100644 index 00000000000..5d08bd4bc3d --- /dev/null +++ b/test/language/expressions/class/decorator/method/public/static/context-static-true.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-static-true.case +// - src/decorator/methods/standard/public/static/cls-expr.template +/*--- +description: Context `static` is false for all types of instance elements (public static method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.static, true); +} + + +var C = class { + @dec + static element() { + return 123; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/method/public/static/decorator-order-application-method-and-class.js b/test/language/expressions/class/decorator/method/public/static/decorator-order-application-method-and-class.js new file mode 100644 index 00000000000..aa6ffc81a55 --- /dev/null +++ b/test/language/expressions/class/decorator/method/public/static/decorator-order-application-method-and-class.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-order-application-method-and-class.case +// - src/decorator/methods/standard/public/static/cls-expr.template +/*--- +description: Order of decorator application for elements without initializers (public static method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +var ord = []; + +function pushOrd(applyOrd, extraInitOrd) { + return (value, context) => { + ord.push(applyOrd); + context.addInitializer(() => ord.push(extraInitOrd)); + } +} + + +var C = class { + @pushOrd(1, 3) + @pushOrd(0, 2) + + static element() { + return 123; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + +assert.sameValue(ord.length, 4); +ord.forEach(assert.sameValue); diff --git a/test/language/expressions/class/decorator/method/public/static/method-deco-returns-replacement.js b/test/language/expressions/class/decorator/method/public/static/method-deco-returns-replacement.js new file mode 100644 index 00000000000..d2998692334 --- /dev/null +++ b/test/language/expressions/class/decorator/method/public/static/method-deco-returns-replacement.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-deco-returns-replacement.case +// - src/decorator/methods/standard/public/static/cls-expr.template +/*--- +description: Can replace a decorated method with a new method (public static method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(value, context) { + assert.sameValue(value(), 123); + + return () => 456; +} + + +var C = class { + @dec + + static element() { + return 123; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/expressions/class/decorator/method/public/static/method-deco-returns-undefined.js b/test/language/expressions/class/decorator/method/public/static/method-deco-returns-undefined.js new file mode 100644 index 00000000000..412b703f3f4 --- /dev/null +++ b/test/language/expressions/class/decorator/method/public/static/method-deco-returns-undefined.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-deco-returns-undefined.case +// - src/decorator/methods/standard/public/static/cls-expr.template +/*--- +description: Decorator undefined return defaults to previous value (public static method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec1(value, context) { + assert.sameValue(value(), 123); + + return () => 456; +} + +function dec2(value, context) { + assert.sameValue(value(), 456); +} + + +var C = class { + @dec2 @dec1 + + static element() { + return 123; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/expressions/class/decorator/method/public/static/method-generator-deco-returns-replacement.js b/test/language/expressions/class/decorator/method/public/static/method-generator-deco-returns-replacement.js new file mode 100644 index 00000000000..9802621dfe0 --- /dev/null +++ b/test/language/expressions/class/decorator/method/public/static/method-generator-deco-returns-replacement.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-generator-deco-returns-replacement.case +// - src/decorator/methods/generator/public/static/cls-expr.template +/*--- +description: Can replace a decorated method with a new method (public static method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(value, context) { + assert(value() instanceof Iterator, 'value is iterator'); + + return () => 456; +} + + +var C = class { + @dec + + static * element() { + return 123; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/expressions/class/decorator/method/public/static/method-generator-deco-returns-undefined.js b/test/language/expressions/class/decorator/method/public/static/method-generator-deco-returns-undefined.js new file mode 100644 index 00000000000..e736946e97e --- /dev/null +++ b/test/language/expressions/class/decorator/method/public/static/method-generator-deco-returns-undefined.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-generator-deco-returns-undefined.case +// - src/decorator/methods/generator/public/static/cls-expr.template +/*--- +description: Decorator undefined return defaults to previous value (public static method decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec1(value, context) { + assert(value() instanceof Iterator, 'value is iterator'); + + return () => 456; +} + +function dec2(value, context) { + assert.sameValue(value(), 456); +} + + +var C = class { + @dec2 @dec1 + + static * element() { + return 123; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/expressions/class/decorator/setter/error/private/instance/setter-deco-returns-invalid.js b/test/language/expressions/class/decorator/setter/error/private/instance/setter-deco-returns-invalid.js new file mode 100644 index 00000000000..713ea1bd82b --- /dev/null +++ b/test/language/expressions/class/decorator/setter/error/private/instance/setter-deco-returns-invalid.js @@ -0,0 +1,26 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/setter-deco-returns-invalid.case +// - src/decorator/setters/error/private/instance/cls-expr.template +/*--- +description: Decorator can't return an invalid value (private setter decorator evaluation error in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + return 123; +} + + +function evaluate() { + var C = class { + @dec + + set #element(value) {} + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/expressions/class/decorator/setter/error/private/static/setter-deco-returns-invalid.js b/test/language/expressions/class/decorator/setter/error/private/static/setter-deco-returns-invalid.js new file mode 100644 index 00000000000..84386a06c1f --- /dev/null +++ b/test/language/expressions/class/decorator/setter/error/private/static/setter-deco-returns-invalid.js @@ -0,0 +1,25 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/setter-deco-returns-invalid.case +// - src/decorator/setters/error/private/static/cls-expr.template +/*--- +description: Decorator can't return an invalid value (private static setter decorator evaluation error in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + return 123; +} + + +function evaluate() { + var C = class { + @dec + + static set #element(value) {} + } +} + +assert.throws(TypeError, evaluate); diff --git a/test/language/expressions/class/decorator/setter/error/public/instance/setter-deco-returns-invalid.js b/test/language/expressions/class/decorator/setter/error/public/instance/setter-deco-returns-invalid.js new file mode 100644 index 00000000000..e2b513b2577 --- /dev/null +++ b/test/language/expressions/class/decorator/setter/error/public/instance/setter-deco-returns-invalid.js @@ -0,0 +1,26 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/setter-deco-returns-invalid.case +// - src/decorator/setters/error/public/instance/cls-expr.template +/*--- +description: Decorator can't return an invalid value (public setter decorator evaluation error in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + return 123; +} + + +function evaluate() { + var C = class { + @dec + + set element(value) {} + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/expressions/class/decorator/setter/error/public/static/setter-deco-returns-invalid.js b/test/language/expressions/class/decorator/setter/error/public/static/setter-deco-returns-invalid.js new file mode 100644 index 00000000000..3dfa5f571c7 --- /dev/null +++ b/test/language/expressions/class/decorator/setter/error/public/static/setter-deco-returns-invalid.js @@ -0,0 +1,25 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/setter-deco-returns-invalid.case +// - src/decorator/setters/error/public/static/cls-expr.template +/*--- +description: Decorator can't return an invalid value (public static setter decorator evaluation error in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + return 123; +} + + +function evaluate() { + var C = class { + @dec + + static set element(value) {} + } +} + +assert.throws(TypeError, evaluate); diff --git a/test/language/expressions/class/decorator/setter/private/instance/context-access-set.js b/test/language/expressions/class/decorator/setter/private/instance/context-access-set.js new file mode 100644 index 00000000000..0c367772939 --- /dev/null +++ b/test/language/expressions/class/decorator/setter/private/instance/context-access-set.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-set.case +// - src/decorator/setters/standard/private/instance/cls-expr.template +/*--- +description: Context access `get` works on all gettable types of values (private setter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + +var C = class { + internalValue = 123; + + @dec + + set #element(value) { + this.internalValue = value; + } + + getElement() { + return this.internalValue; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/setter/private/instance/context-kind-setter.js b/test/language/expressions/class/decorator/setter/private/instance/context-kind-setter.js new file mode 100644 index 00000000000..1267260be7d --- /dev/null +++ b/test/language/expressions/class/decorator/setter/private/instance/context-kind-setter.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-setter.case +// - src/decorator/setters/standard/private/instance/cls-expr.template +/*--- +description: Context kind is the string "setter" when decorating a method (private setter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "setter"); +} + +var C = class { + internalValue = 123; + + @dec + set #element(value) { + this.internalValue = value; + } + + getElement() { + return this.internalValue; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/setter/private/instance/context-name-private.js b/test/language/expressions/class/decorator/setter/private/instance/context-name-private.js new file mode 100644 index 00000000000..9e7e6dae3b4 --- /dev/null +++ b/test/language/expressions/class/decorator/setter/private/instance/context-name-private.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-private.case +// - src/decorator/setters/standard/private/instance/cls-expr.template +/*--- +description: Context name is correct for all types of private elements (private setter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "#element"); +} + +var C = class { + internalValue = 123; + + @dec + set #element(value) { + this.internalValue = value; + } + + getElement() { + return this.internalValue; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/setter/private/instance/context-private-false.js b/test/language/expressions/class/decorator/setter/private/instance/context-private-false.js new file mode 100644 index 00000000000..e5c0f5f89d8 --- /dev/null +++ b/test/language/expressions/class/decorator/setter/private/instance/context-private-false.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-private-false.case +// - src/decorator/setters/standard/private/instance/cls-expr.template +/*--- +description: Context `private` is true for all types of private elements (private setter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.private, true); +} + +var C = class { + internalValue = 123; + + @dec + set #element(value) { + this.internalValue = value; + } + + getElement() { + return this.internalValue; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/setter/private/instance/context-static-false.js b/test/language/expressions/class/decorator/setter/private/instance/context-static-false.js new file mode 100644 index 00000000000..e1c2afc0c5b --- /dev/null +++ b/test/language/expressions/class/decorator/setter/private/instance/context-static-false.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-static-false.case +// - src/decorator/setters/standard/private/instance/cls-expr.template +/*--- +description: Context `static` is false for all types of instance elements (private setter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.static, false); +} + +var C = class { + internalValue = 123; + + @dec + set #element(value) { + this.internalValue = value; + } + + getElement() { + return this.internalValue; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/setter/private/instance/setter-deco-returns-replacement.js b/test/language/expressions/class/decorator/setter/private/instance/setter-deco-returns-replacement.js new file mode 100644 index 00000000000..67e29c6014c --- /dev/null +++ b/test/language/expressions/class/decorator/setter/private/instance/setter-deco-returns-replacement.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/setter-deco-returns-replacement.case +// - src/decorator/setters/standard/private/instance/cls-expr.template +/*--- +description: Can replace a decorated setter with a new setter (private setter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(set, context) { + return function (v) { + assert.sameValue(v, 456); + set.call(this, 789); + }; +} + +var C = class { + internalValue = 123; + + @dec + + set #element(value) { + this.internalValue = value; + } + + getElement() { + return this.internalValue; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 123); +classOrInstance.setElement(456); +assert.sameValue(classOrInstance.getElement(), 789); diff --git a/test/language/expressions/class/decorator/setter/private/instance/setter-deco-returns-undefined.js b/test/language/expressions/class/decorator/setter/private/instance/setter-deco-returns-undefined.js new file mode 100644 index 00000000000..012c7a0de85 --- /dev/null +++ b/test/language/expressions/class/decorator/setter/private/instance/setter-deco-returns-undefined.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/setter-deco-returns-undefined.case +// - src/decorator/setters/standard/private/instance/cls-expr.template +/*--- +description: Decorator undefined return defaults to previous value (private setter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +var value; + +function dec1(set, context) { + return function (v) { + assert.sameValue(v, 456); + set.call(this, 789); + }; +} + +function dec2(value, context) { + // do nothing +} + +var C = class { + internalValue = 123; + + @dec2 @dec1 + + set #element(value) { + this.internalValue = value; + } + + getElement() { + return this.internalValue; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 123); +classOrInstance.setElement(456); +assert.sameValue(classOrInstance.getElement(), 789); diff --git a/test/language/expressions/class/decorator/setter/private/static/context-access-set.js b/test/language/expressions/class/decorator/setter/private/static/context-access-set.js new file mode 100644 index 00000000000..3a5b881b826 --- /dev/null +++ b/test/language/expressions/class/decorator/setter/private/static/context-access-set.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-set.case +// - src/decorator/setters/standard/private/static/cls-expr.template +/*--- +description: Context access `get` works on all gettable types of values (private static setter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + +var C = class { + static internalValue = 123; + + @dec + + static set #element(value) { + this.internalValue = value; + } + + static getElement() { + return this.internalValue; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/setter/private/static/context-kind-setter.js b/test/language/expressions/class/decorator/setter/private/static/context-kind-setter.js new file mode 100644 index 00000000000..b1a27b68a7c --- /dev/null +++ b/test/language/expressions/class/decorator/setter/private/static/context-kind-setter.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-setter.case +// - src/decorator/setters/standard/private/static/cls-expr.template +/*--- +description: Context kind is the string "setter" when decorating a method (private static setter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "setter"); +} + +var C = class { + static internalValue = 123; + + @dec + static set #element(value) { + this.internalValue = value; + } + + static getElement() { + return this.internalValue; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/setter/private/static/context-name-private.js b/test/language/expressions/class/decorator/setter/private/static/context-name-private.js new file mode 100644 index 00000000000..6bd79a9d155 --- /dev/null +++ b/test/language/expressions/class/decorator/setter/private/static/context-name-private.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-private.case +// - src/decorator/setters/standard/private/static/cls-expr.template +/*--- +description: Context name is correct for all types of private elements (private static setter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "#element"); +} + +var C = class { + static internalValue = 123; + + @dec + static set #element(value) { + this.internalValue = value; + } + + static getElement() { + return this.internalValue; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/setter/private/static/context-private-false.js b/test/language/expressions/class/decorator/setter/private/static/context-private-false.js new file mode 100644 index 00000000000..70799a989e6 --- /dev/null +++ b/test/language/expressions/class/decorator/setter/private/static/context-private-false.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-private-false.case +// - src/decorator/setters/standard/private/static/cls-expr.template +/*--- +description: Context `private` is true for all types of private elements (private static setter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.private, true); +} + +var C = class { + static internalValue = 123; + + @dec + static set #element(value) { + this.internalValue = value; + } + + static getElement() { + return this.internalValue; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/setter/private/static/context-static-true.js b/test/language/expressions/class/decorator/setter/private/static/context-static-true.js new file mode 100644 index 00000000000..79e6a44dc53 --- /dev/null +++ b/test/language/expressions/class/decorator/setter/private/static/context-static-true.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-static-true.case +// - src/decorator/setters/standard/private/static/cls-expr.template +/*--- +description: Context `static` is false for all types of instance elements (private static setter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.static, true); +} + +var C = class { + static internalValue = 123; + + @dec + static set #element(value) { + this.internalValue = value; + } + + static getElement() { + return this.internalValue; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/setter/private/static/setter-deco-returns-replacement.js b/test/language/expressions/class/decorator/setter/private/static/setter-deco-returns-replacement.js new file mode 100644 index 00000000000..a83909e2a8e --- /dev/null +++ b/test/language/expressions/class/decorator/setter/private/static/setter-deco-returns-replacement.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/setter-deco-returns-replacement.case +// - src/decorator/setters/standard/private/static/cls-expr.template +/*--- +description: Can replace a decorated setter with a new setter (private static setter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(set, context) { + return function (v) { + assert.sameValue(v, 456); + set.call(this, 789); + }; +} + +var C = class { + static internalValue = 123; + + @dec + + static set #element(value) { + this.internalValue = value; + } + + static getElement() { + return this.internalValue; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 123); +classOrInstance.setElement(456); +assert.sameValue(classOrInstance.getElement(), 789); diff --git a/test/language/expressions/class/decorator/setter/private/static/setter-deco-returns-undefined.js b/test/language/expressions/class/decorator/setter/private/static/setter-deco-returns-undefined.js new file mode 100644 index 00000000000..878b5963cb3 --- /dev/null +++ b/test/language/expressions/class/decorator/setter/private/static/setter-deco-returns-undefined.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/setter-deco-returns-undefined.case +// - src/decorator/setters/standard/private/static/cls-expr.template +/*--- +description: Decorator undefined return defaults to previous value (private static setter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +var value; + +function dec1(set, context) { + return function (v) { + assert.sameValue(v, 456); + set.call(this, 789); + }; +} + +function dec2(value, context) { + // do nothing +} + +var C = class { + static internalValue = 123; + + @dec2 @dec1 + + static set #element(value) { + this.internalValue = value; + } + + static getElement() { + return this.internalValue; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 123); +classOrInstance.setElement(456); +assert.sameValue(classOrInstance.getElement(), 789); diff --git a/test/language/expressions/class/decorator/setter/public/instance/context-access-set.js b/test/language/expressions/class/decorator/setter/public/instance/context-access-set.js new file mode 100644 index 00000000000..0d0b3cd17a2 --- /dev/null +++ b/test/language/expressions/class/decorator/setter/public/instance/context-access-set.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-set.case +// - src/decorator/setters/standard/public/instance/cls-expr.template +/*--- +description: Context access `get` works on all gettable types of values (public setter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + +var C = class { + internalValue = 123; + + @dec + + set element(value) { + this.internalValue = value; + } + + getElement() { + return this.internalValue; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/setter/public/instance/context-kind-setter.js b/test/language/expressions/class/decorator/setter/public/instance/context-kind-setter.js new file mode 100644 index 00000000000..8ce2dec4acf --- /dev/null +++ b/test/language/expressions/class/decorator/setter/public/instance/context-kind-setter.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-setter.case +// - src/decorator/setters/standard/public/instance/cls-expr.template +/*--- +description: Context kind is the string "setter" when decorating a method (public setter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "setter"); +} + +var C = class { + internalValue = 123; + + @dec + set element(value) { + this.internalValue = value; + } + + getElement() { + return this.internalValue; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/setter/public/instance/context-name-public.js b/test/language/expressions/class/decorator/setter/public/instance/context-name-public.js new file mode 100644 index 00000000000..d2a41c1b9f6 --- /dev/null +++ b/test/language/expressions/class/decorator/setter/public/instance/context-name-public.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-public.case +// - src/decorator/setters/standard/public/instance/cls-expr.template +/*--- +description: Context name is correct for all types of public elements (public setter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "element"); +} + +var C = class { + internalValue = 123; + + @dec + set element(value) { + this.internalValue = value; + } + + getElement() { + return this.internalValue; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/setter/public/instance/context-private-true.js b/test/language/expressions/class/decorator/setter/public/instance/context-private-true.js new file mode 100644 index 00000000000..47205b69d7b --- /dev/null +++ b/test/language/expressions/class/decorator/setter/public/instance/context-private-true.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-private-true.case +// - src/decorator/setters/standard/public/instance/cls-expr.template +/*--- +description: Context `private` is false for all types of public elements (public setter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.private, false); +} + +var C = class { + internalValue = 123; + + @dec + set element(value) { + this.internalValue = value; + } + + getElement() { + return this.internalValue; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/setter/public/instance/context-static-false.js b/test/language/expressions/class/decorator/setter/public/instance/context-static-false.js new file mode 100644 index 00000000000..5f309b06d31 --- /dev/null +++ b/test/language/expressions/class/decorator/setter/public/instance/context-static-false.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-static-false.case +// - src/decorator/setters/standard/public/instance/cls-expr.template +/*--- +description: Context `static` is false for all types of instance elements (public setter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.static, false); +} + +var C = class { + internalValue = 123; + + @dec + set element(value) { + this.internalValue = value; + } + + getElement() { + return this.internalValue; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/expressions/class/decorator/setter/public/instance/setter-deco-returns-replacement.js b/test/language/expressions/class/decorator/setter/public/instance/setter-deco-returns-replacement.js new file mode 100644 index 00000000000..8bcd07ed6e8 --- /dev/null +++ b/test/language/expressions/class/decorator/setter/public/instance/setter-deco-returns-replacement.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/setter-deco-returns-replacement.case +// - src/decorator/setters/standard/public/instance/cls-expr.template +/*--- +description: Can replace a decorated setter with a new setter (public setter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(set, context) { + return function (v) { + assert.sameValue(v, 456); + set.call(this, 789); + }; +} + +var C = class { + internalValue = 123; + + @dec + + set element(value) { + this.internalValue = value; + } + + getElement() { + return this.internalValue; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 123); +classOrInstance.setElement(456); +assert.sameValue(classOrInstance.getElement(), 789); diff --git a/test/language/expressions/class/decorator/setter/public/instance/setter-deco-returns-undefined.js b/test/language/expressions/class/decorator/setter/public/instance/setter-deco-returns-undefined.js new file mode 100644 index 00000000000..a6c52cd3b63 --- /dev/null +++ b/test/language/expressions/class/decorator/setter/public/instance/setter-deco-returns-undefined.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/setter-deco-returns-undefined.case +// - src/decorator/setters/standard/public/instance/cls-expr.template +/*--- +description: Decorator undefined return defaults to previous value (public setter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +var value; + +function dec1(set, context) { + return function (v) { + assert.sameValue(v, 456); + set.call(this, 789); + }; +} + +function dec2(value, context) { + // do nothing +} + +var C = class { + internalValue = 123; + + @dec2 @dec1 + + set element(value) { + this.internalValue = value; + } + + getElement() { + return this.internalValue; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 123); +classOrInstance.setElement(456); +assert.sameValue(classOrInstance.getElement(), 789); diff --git a/test/language/expressions/class/decorator/setter/public/static/context-access-set.js b/test/language/expressions/class/decorator/setter/public/static/context-access-set.js new file mode 100644 index 00000000000..97dc6cd5853 --- /dev/null +++ b/test/language/expressions/class/decorator/setter/public/static/context-access-set.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-set.case +// - src/decorator/setters/standard/public/static/cls-expr.template +/*--- +description: Context access `get` works on all gettable types of values (public static setter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + +var C = class { + static internalValue = 123; + + @dec + + static set element(value) { + this.internalValue = value; + } + + static getElement() { + return this.internalValue; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/expressions/class/decorator/setter/public/static/context-kind-setter.js b/test/language/expressions/class/decorator/setter/public/static/context-kind-setter.js new file mode 100644 index 00000000000..17698091bf6 --- /dev/null +++ b/test/language/expressions/class/decorator/setter/public/static/context-kind-setter.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-setter.case +// - src/decorator/setters/standard/public/static/cls-expr.template +/*--- +description: Context kind is the string "setter" when decorating a method (public static setter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "setter"); +} + +var C = class { + static internalValue = 123; + + @dec + static set element(value) { + this.internalValue = value; + } + + static getElement() { + return this.internalValue; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/setter/public/static/context-name-public.js b/test/language/expressions/class/decorator/setter/public/static/context-name-public.js new file mode 100644 index 00000000000..fbe6a9bdb63 --- /dev/null +++ b/test/language/expressions/class/decorator/setter/public/static/context-name-public.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-public.case +// - src/decorator/setters/standard/public/static/cls-expr.template +/*--- +description: Context name is correct for all types of public elements (public static setter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "element"); +} + +var C = class { + static internalValue = 123; + + @dec + static set element(value) { + this.internalValue = value; + } + + static getElement() { + return this.internalValue; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/setter/public/static/context-private-true.js b/test/language/expressions/class/decorator/setter/public/static/context-private-true.js new file mode 100644 index 00000000000..1f8dcecc7df --- /dev/null +++ b/test/language/expressions/class/decorator/setter/public/static/context-private-true.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-private-true.case +// - src/decorator/setters/standard/public/static/cls-expr.template +/*--- +description: Context `private` is false for all types of public elements (public static setter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.private, false); +} + +var C = class { + static internalValue = 123; + + @dec + static set element(value) { + this.internalValue = value; + } + + static getElement() { + return this.internalValue; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/setter/public/static/context-static-true.js b/test/language/expressions/class/decorator/setter/public/static/context-static-true.js new file mode 100644 index 00000000000..53081b2286d --- /dev/null +++ b/test/language/expressions/class/decorator/setter/public/static/context-static-true.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-static-true.case +// - src/decorator/setters/standard/public/static/cls-expr.template +/*--- +description: Context `static` is false for all types of instance elements (public static setter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.static, true); +} + +var C = class { + static internalValue = 123; + + @dec + static set element(value) { + this.internalValue = value; + } + + static getElement() { + return this.internalValue; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/expressions/class/decorator/setter/public/static/setter-deco-returns-replacement.js b/test/language/expressions/class/decorator/setter/public/static/setter-deco-returns-replacement.js new file mode 100644 index 00000000000..01afe6adee5 --- /dev/null +++ b/test/language/expressions/class/decorator/setter/public/static/setter-deco-returns-replacement.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/setter-deco-returns-replacement.case +// - src/decorator/setters/standard/public/static/cls-expr.template +/*--- +description: Can replace a decorated setter with a new setter (public static setter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(set, context) { + return function (v) { + assert.sameValue(v, 456); + set.call(this, 789); + }; +} + +var C = class { + static internalValue = 123; + + @dec + + static set element(value) { + this.internalValue = value; + } + + static getElement() { + return this.internalValue; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 123); +classOrInstance.setElement(456); +assert.sameValue(classOrInstance.getElement(), 789); diff --git a/test/language/expressions/class/decorator/setter/public/static/setter-deco-returns-undefined.js b/test/language/expressions/class/decorator/setter/public/static/setter-deco-returns-undefined.js new file mode 100644 index 00000000000..d0b3e6ef293 --- /dev/null +++ b/test/language/expressions/class/decorator/setter/public/static/setter-deco-returns-undefined.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/setter-deco-returns-undefined.case +// - src/decorator/setters/standard/public/static/cls-expr.template +/*--- +description: Decorator undefined return defaults to previous value (public static setter decorator behavior in class expression) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +var value; + +function dec1(set, context) { + return function (v) { + assert.sameValue(v, 456); + set.call(this, 789); + }; +} + +function dec2(value, context) { + // do nothing +} + +var C = class { + static internalValue = 123; + + @dec2 @dec1 + + static set element(value) { + this.internalValue = value; + } + + static getElement() { + return this.internalValue; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 123); +classOrInstance.setElement(456); +assert.sameValue(classOrInstance.getElement(), 789); diff --git a/test/language/statements/class/decorator/accessor/error/private/instance/accessor-deco-invalid-return-get.js b/test/language/statements/class/decorator/accessor/error/private/instance/accessor-deco-invalid-return-get.js new file mode 100644 index 00000000000..4b837604b77 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/error/private/instance/accessor-deco-invalid-return-get.js @@ -0,0 +1,27 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-invalid-return-get.case +// - src/decorator/accessors/error/private/instance/cls-decl.template +/*--- +description: Accessor decorator cannot return invalid getter (private acessor decorator evaluation error in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec() { + return { + get: 123 + }; +} + + +function evaluate() { + class C { + @dec + + accessor #element; + } +} + +assert.throws(TypeError, evaluate); diff --git a/test/language/statements/class/decorator/accessor/error/private/instance/accessor-deco-invalid-return-init.js b/test/language/statements/class/decorator/accessor/error/private/instance/accessor-deco-invalid-return-init.js new file mode 100644 index 00000000000..19cfd7ac6b8 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/error/private/instance/accessor-deco-invalid-return-init.js @@ -0,0 +1,27 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-invalid-return-init.case +// - src/decorator/accessors/error/private/instance/cls-decl.template +/*--- +description: Accessor decorator cannot return invalid init (private acessor decorator evaluation error in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec() { + return { + init: 123 + }; +} + + +function evaluate() { + class C { + @dec + + accessor #element; + } +} + +assert.throws(TypeError, evaluate); diff --git a/test/language/statements/class/decorator/accessor/error/private/instance/accessor-deco-invalid-return-set.js b/test/language/statements/class/decorator/accessor/error/private/instance/accessor-deco-invalid-return-set.js new file mode 100644 index 00000000000..e9dbda6b00b --- /dev/null +++ b/test/language/statements/class/decorator/accessor/error/private/instance/accessor-deco-invalid-return-set.js @@ -0,0 +1,27 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-invalid-return-set.case +// - src/decorator/accessors/error/private/instance/cls-decl.template +/*--- +description: Accessor decorator cannot return invalid setter (private acessor decorator evaluation error in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec() { + return { + set: 123 + }; +} + + +function evaluate() { + class C { + @dec + + accessor #element; + } +} + +assert.throws(TypeError, evaluate); diff --git a/test/language/statements/class/decorator/accessor/error/private/instance/accessor-deco-invalid-return.js b/test/language/statements/class/decorator/accessor/error/private/instance/accessor-deco-invalid-return.js new file mode 100644 index 00000000000..4d3f2aa0140 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/error/private/instance/accessor-deco-invalid-return.js @@ -0,0 +1,25 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-invalid-return.case +// - src/decorator/accessors/error/private/instance/cls-decl.template +/*--- +description: Accessor decorator cannot return invalid init (private acessor decorator evaluation error in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec() { + return 123; +} + + +function evaluate() { + class C { + @dec + + accessor #element; + } +} + +assert.throws(TypeError, evaluate); diff --git a/test/language/statements/class/decorator/accessor/error/private/static/accessor-deco-invalid-return-get.js b/test/language/statements/class/decorator/accessor/error/private/static/accessor-deco-invalid-return-get.js new file mode 100644 index 00000000000..f90f55ffbc5 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/error/private/static/accessor-deco-invalid-return-get.js @@ -0,0 +1,28 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-invalid-return-get.case +// - src/decorator/accessors/error/private/static/cls-decl.template +/*--- +description: Accessor decorator cannot return invalid getter (private static acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec() { + return { + get: 123 + }; +} + + +function evaluate() { + class C { + @dec + + static accessor #element; + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/statements/class/decorator/accessor/error/private/static/accessor-deco-invalid-return-init.js b/test/language/statements/class/decorator/accessor/error/private/static/accessor-deco-invalid-return-init.js new file mode 100644 index 00000000000..ce5b7a275dc --- /dev/null +++ b/test/language/statements/class/decorator/accessor/error/private/static/accessor-deco-invalid-return-init.js @@ -0,0 +1,28 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-invalid-return-init.case +// - src/decorator/accessors/error/private/static/cls-decl.template +/*--- +description: Accessor decorator cannot return invalid init (private static acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec() { + return { + init: 123 + }; +} + + +function evaluate() { + class C { + @dec + + static accessor #element; + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/statements/class/decorator/accessor/error/private/static/accessor-deco-invalid-return-set.js b/test/language/statements/class/decorator/accessor/error/private/static/accessor-deco-invalid-return-set.js new file mode 100644 index 00000000000..c47c99d9802 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/error/private/static/accessor-deco-invalid-return-set.js @@ -0,0 +1,28 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-invalid-return-set.case +// - src/decorator/accessors/error/private/static/cls-decl.template +/*--- +description: Accessor decorator cannot return invalid setter (private static acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec() { + return { + set: 123 + }; +} + + +function evaluate() { + class C { + @dec + + static accessor #element; + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/statements/class/decorator/accessor/error/private/static/accessor-deco-invalid-return.js b/test/language/statements/class/decorator/accessor/error/private/static/accessor-deco-invalid-return.js new file mode 100644 index 00000000000..5697c09bedc --- /dev/null +++ b/test/language/statements/class/decorator/accessor/error/private/static/accessor-deco-invalid-return.js @@ -0,0 +1,26 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-invalid-return.case +// - src/decorator/accessors/error/private/static/cls-decl.template +/*--- +description: Accessor decorator cannot return invalid init (private static acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec() { + return 123; +} + + +function evaluate() { + class C { + @dec + + static accessor #element; + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/statements/class/decorator/accessor/error/public/instance/accessor-deco-invalid-return-get.js b/test/language/statements/class/decorator/accessor/error/public/instance/accessor-deco-invalid-return-get.js new file mode 100644 index 00000000000..4389ce40f8b --- /dev/null +++ b/test/language/statements/class/decorator/accessor/error/public/instance/accessor-deco-invalid-return-get.js @@ -0,0 +1,28 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-invalid-return-get.case +// - src/decorator/accessors/error/public/instance/cls-decl.template +/*--- +description: Accessor decorator cannot return invalid getter (public acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec() { + return { + get: 123 + }; +} + + +function evaluate() { + class C { + @dec + + accessor element; + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/statements/class/decorator/accessor/error/public/instance/accessor-deco-invalid-return-init.js b/test/language/statements/class/decorator/accessor/error/public/instance/accessor-deco-invalid-return-init.js new file mode 100644 index 00000000000..35f9c9147fc --- /dev/null +++ b/test/language/statements/class/decorator/accessor/error/public/instance/accessor-deco-invalid-return-init.js @@ -0,0 +1,28 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-invalid-return-init.case +// - src/decorator/accessors/error/public/instance/cls-decl.template +/*--- +description: Accessor decorator cannot return invalid init (public acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec() { + return { + init: 123 + }; +} + + +function evaluate() { + class C { + @dec + + accessor element; + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/statements/class/decorator/accessor/error/public/instance/accessor-deco-invalid-return-set.js b/test/language/statements/class/decorator/accessor/error/public/instance/accessor-deco-invalid-return-set.js new file mode 100644 index 00000000000..fb765728e85 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/error/public/instance/accessor-deco-invalid-return-set.js @@ -0,0 +1,28 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-invalid-return-set.case +// - src/decorator/accessors/error/public/instance/cls-decl.template +/*--- +description: Accessor decorator cannot return invalid setter (public acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec() { + return { + set: 123 + }; +} + + +function evaluate() { + class C { + @dec + + accessor element; + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/statements/class/decorator/accessor/error/public/instance/accessor-deco-invalid-return.js b/test/language/statements/class/decorator/accessor/error/public/instance/accessor-deco-invalid-return.js new file mode 100644 index 00000000000..91cd167526b --- /dev/null +++ b/test/language/statements/class/decorator/accessor/error/public/instance/accessor-deco-invalid-return.js @@ -0,0 +1,26 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-invalid-return.case +// - src/decorator/accessors/error/public/instance/cls-decl.template +/*--- +description: Accessor decorator cannot return invalid init (public acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec() { + return 123; +} + + +function evaluate() { + class C { + @dec + + accessor element; + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/statements/class/decorator/accessor/private/instance/accessor-deco-returns-get.js b/test/language/statements/class/decorator/accessor/private/instance/accessor-deco-returns-get.js new file mode 100644 index 00000000000..4175856a1a4 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/private/instance/accessor-deco-returns-get.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-returns-get.case +// - src/decorator/accessors/standard/private/instance/cls-decl.template +/*--- +description: Accessor decorator can return a new getter (private acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec({ get }) { + return { + get() { + assert.sameValue(get.call(this), undefined); + return 123; + } + }; +} + + +class C { + @dec + + accessor #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 123); diff --git a/test/language/statements/class/decorator/accessor/private/instance/accessor-deco-returns-init.js b/test/language/statements/class/decorator/accessor/private/instance/accessor-deco-returns-init.js new file mode 100644 index 00000000000..d53fc9194e6 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/private/instance/accessor-deco-returns-init.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-returns-init.case +// - src/decorator/accessors/standard/private/instance/cls-decl.template +/*--- +description: Accessor decorator can return a new init (private acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec() { + return { + init(value) { + assert.sameValue(value, undefined); + return 123; + } + }; +} + + +class C { + @dec + + accessor #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 123); +classOrInstance.setElement(456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/accessor/private/instance/accessor-deco-returns-set.js b/test/language/statements/class/decorator/accessor/private/instance/accessor-deco-returns-set.js new file mode 100644 index 00000000000..277a9b30c49 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/private/instance/accessor-deco-returns-set.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-returns-set.case +// - src/decorator/accessors/standard/private/instance/cls-decl.template +/*--- +description: Accessor decorator can return a new getter (private acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec({ set }) { + return { + set(value) { + assert.sameValue(value, 123); + set.call(this, 456); + } + }; +} + + +class C { + @dec + + accessor #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), undefined); +classOrInstance.setElement(123); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/accessor/private/instance/context-access-get.js b/test/language/statements/class/decorator/accessor/private/instance/context-access-get.js new file mode 100644 index 00000000000..d8cbdb7cec4 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/private/instance/context-access-get.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-get.case +// - src/decorator/accessors/standard/private/instance/cls-decl.template +/*--- +description: Context access `get` works on all gettable types of values (private acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +class C { + @dec + + accessor #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), access.get(classOrInstance)); diff --git a/test/language/statements/class/decorator/accessor/private/instance/context-access-set.js b/test/language/statements/class/decorator/accessor/private/instance/context-access-set.js new file mode 100644 index 00000000000..08cb5b42642 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/private/instance/context-access-set.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-set.case +// - src/decorator/accessors/standard/private/instance/cls-decl.template +/*--- +description: Context access `get` works on all gettable types of values (private acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +class C { + @dec + + accessor #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/accessor/private/instance/context-kind-accessor.js b/test/language/statements/class/decorator/accessor/private/instance/context-kind-accessor.js new file mode 100644 index 00000000000..0afa419a910 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/private/instance/context-kind-accessor.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-accessor.case +// - src/decorator/accessors/standard/private/instance/cls-decl.template +/*--- +description: Context kind is the string "accessor" when decorating a method (private acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "accessor"); +} + + +class C { + @dec + accessor #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/statements/class/decorator/accessor/private/instance/context-name-private.js b/test/language/statements/class/decorator/accessor/private/instance/context-name-private.js new file mode 100644 index 00000000000..6ef7e84cf2d --- /dev/null +++ b/test/language/statements/class/decorator/accessor/private/instance/context-name-private.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-private.case +// - src/decorator/accessors/standard/private/instance/cls-decl.template +/*--- +description: Context name is correct for all types of private elements (private acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "#element"); +} + + +class C { + @dec + accessor #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/statements/class/decorator/accessor/private/instance/context-private-false.js b/test/language/statements/class/decorator/accessor/private/instance/context-private-false.js new file mode 100644 index 00000000000..50047628f63 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/private/instance/context-private-false.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-private-false.case +// - src/decorator/accessors/standard/private/instance/cls-decl.template +/*--- +description: Context `private` is true for all types of private elements (private acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.private, true); +} + + +class C { + @dec + accessor #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/statements/class/decorator/accessor/private/instance/context-static-false.js b/test/language/statements/class/decorator/accessor/private/instance/context-static-false.js new file mode 100644 index 00000000000..8eeb4facf02 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/private/instance/context-static-false.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-static-false.case +// - src/decorator/accessors/standard/private/instance/cls-decl.template +/*--- +description: Context `static` is false for all types of instance elements (private acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.static, false); +} + + +class C { + @dec + accessor #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/statements/class/decorator/accessor/private/instance/field-and-accessor-init-this.js b/test/language/statements/class/decorator/accessor/private/instance/field-and-accessor-init-this.js new file mode 100644 index 00000000000..1e209559cf1 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/private/instance/field-and-accessor-init-this.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/accessors/standard/private/instance/cls-decl.template +/*--- +description: Field initializer `this` value is the instance or the class (private acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +class C { + @dec + + accessor #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/statements/class/decorator/accessor/private/static/accessor-deco-returns-get.js b/test/language/statements/class/decorator/accessor/private/static/accessor-deco-returns-get.js new file mode 100644 index 00000000000..4bab66980ab --- /dev/null +++ b/test/language/statements/class/decorator/accessor/private/static/accessor-deco-returns-get.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-returns-get.case +// - src/decorator/accessors/standard/private/static/cls-decl.template +/*--- +description: Accessor decorator can return a new getter (private static acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec({ get }) { + return { + get() { + assert.sameValue(get.call(this), undefined); + return 123; + } + }; +} + + +class C { + @dec + + static accessor #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 123); diff --git a/test/language/statements/class/decorator/accessor/private/static/accessor-deco-returns-init.js b/test/language/statements/class/decorator/accessor/private/static/accessor-deco-returns-init.js new file mode 100644 index 00000000000..5ce4ebce9cb --- /dev/null +++ b/test/language/statements/class/decorator/accessor/private/static/accessor-deco-returns-init.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-returns-init.case +// - src/decorator/accessors/standard/private/static/cls-decl.template +/*--- +description: Accessor decorator can return a new init (private static acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec() { + return { + init(value) { + assert.sameValue(value, undefined); + return 123; + } + }; +} + + +class C { + @dec + + static accessor #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 123); +classOrInstance.setElement(456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/accessor/private/static/accessor-deco-returns-set.js b/test/language/statements/class/decorator/accessor/private/static/accessor-deco-returns-set.js new file mode 100644 index 00000000000..79d781f629b --- /dev/null +++ b/test/language/statements/class/decorator/accessor/private/static/accessor-deco-returns-set.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-returns-set.case +// - src/decorator/accessors/standard/private/static/cls-decl.template +/*--- +description: Accessor decorator can return a new getter (private static acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec({ set }) { + return { + set(value) { + assert.sameValue(value, 123); + set.call(this, 456); + } + }; +} + + +class C { + @dec + + static accessor #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), undefined); +classOrInstance.setElement(123); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/accessor/private/static/context-access-get.js b/test/language/statements/class/decorator/accessor/private/static/context-access-get.js new file mode 100644 index 00000000000..c638b09ea50 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/private/static/context-access-get.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-get.case +// - src/decorator/accessors/standard/private/static/cls-decl.template +/*--- +description: Context access `get` works on all gettable types of values (private static acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +class C { + @dec + + static accessor #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), access.get(classOrInstance)); diff --git a/test/language/statements/class/decorator/accessor/private/static/context-access-set.js b/test/language/statements/class/decorator/accessor/private/static/context-access-set.js new file mode 100644 index 00000000000..531b945ffc7 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/private/static/context-access-set.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-set.case +// - src/decorator/accessors/standard/private/static/cls-decl.template +/*--- +description: Context access `get` works on all gettable types of values (private static acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +class C { + @dec + + static accessor #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/accessor/private/static/context-kind-accessor.js b/test/language/statements/class/decorator/accessor/private/static/context-kind-accessor.js new file mode 100644 index 00000000000..8a68b2fabd4 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/private/static/context-kind-accessor.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-accessor.case +// - src/decorator/accessors/standard/private/static/cls-decl.template +/*--- +description: Context kind is the string "accessor" when decorating a method (private static acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "accessor"); +} + + +class C { + @dec + static accessor #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/accessor/private/static/context-name-private.js b/test/language/statements/class/decorator/accessor/private/static/context-name-private.js new file mode 100644 index 00000000000..ad664311b66 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/private/static/context-name-private.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-private.case +// - src/decorator/accessors/standard/private/static/cls-decl.template +/*--- +description: Context name is correct for all types of private elements (private static acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "#element"); +} + + +class C { + @dec + static accessor #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/accessor/private/static/context-private-false.js b/test/language/statements/class/decorator/accessor/private/static/context-private-false.js new file mode 100644 index 00000000000..170869491e1 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/private/static/context-private-false.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-private-false.case +// - src/decorator/accessors/standard/private/static/cls-decl.template +/*--- +description: Context `private` is true for all types of private elements (private static acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.private, true); +} + + +class C { + @dec + static accessor #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/accessor/private/static/context-static-true.js b/test/language/statements/class/decorator/accessor/private/static/context-static-true.js new file mode 100644 index 00000000000..e880281e92e --- /dev/null +++ b/test/language/statements/class/decorator/accessor/private/static/context-static-true.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-static-true.case +// - src/decorator/accessors/standard/private/static/cls-decl.template +/*--- +description: Context `static` is false for all types of instance elements (private static acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.static, true); +} + + +class C { + @dec + static accessor #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/accessor/private/static/field-and-accessor-init-this.js b/test/language/statements/class/decorator/accessor/private/static/field-and-accessor-init-this.js new file mode 100644 index 00000000000..5a87deac51c --- /dev/null +++ b/test/language/statements/class/decorator/accessor/private/static/field-and-accessor-init-this.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/accessors/standard/private/static/cls-decl.template +/*--- +description: Field initializer `this` value is the instance or the class (private static acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +class C { + @dec + + static accessor #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/statements/class/decorator/accessor/public/instance/accessor-deco-returns-get.js b/test/language/statements/class/decorator/accessor/public/instance/accessor-deco-returns-get.js new file mode 100644 index 00000000000..7de7b214113 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/public/instance/accessor-deco-returns-get.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-returns-get.case +// - src/decorator/accessors/standard/public/instance/cls-decl.template +/*--- +description: Accessor decorator can return a new getter (public acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec({ get }) { + return { + get() { + assert.sameValue(get.call(this), undefined); + return 123; + } + }; +} + + +class C { + @dec + + accessor element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 123); diff --git a/test/language/statements/class/decorator/accessor/public/instance/accessor-deco-returns-init.js b/test/language/statements/class/decorator/accessor/public/instance/accessor-deco-returns-init.js new file mode 100644 index 00000000000..0071b3dfed2 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/public/instance/accessor-deco-returns-init.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-returns-init.case +// - src/decorator/accessors/standard/public/instance/cls-decl.template +/*--- +description: Accessor decorator can return a new init (public acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec() { + return { + init(value) { + assert.sameValue(value, undefined); + return 123; + } + }; +} + + +class C { + @dec + + accessor element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 123); +classOrInstance.setElement(456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/accessor/public/instance/accessor-deco-returns-set.js b/test/language/statements/class/decorator/accessor/public/instance/accessor-deco-returns-set.js new file mode 100644 index 00000000000..628783f7fd6 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/public/instance/accessor-deco-returns-set.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-returns-set.case +// - src/decorator/accessors/standard/public/instance/cls-decl.template +/*--- +description: Accessor decorator can return a new getter (public acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec({ set }) { + return { + set(value) { + assert.sameValue(value, 123); + set.call(this, 456); + } + }; +} + + +class C { + @dec + + accessor element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), undefined); +classOrInstance.setElement(123); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/accessor/public/instance/context-access-get.js b/test/language/statements/class/decorator/accessor/public/instance/context-access-get.js new file mode 100644 index 00000000000..3aea3c88d44 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/public/instance/context-access-get.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-get.case +// - src/decorator/accessors/standard/public/instance/cls-decl.template +/*--- +description: Context access `get` works on all gettable types of values (public acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +class C { + @dec + + accessor element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), access.get(classOrInstance)); diff --git a/test/language/statements/class/decorator/accessor/public/instance/context-access-set.js b/test/language/statements/class/decorator/accessor/public/instance/context-access-set.js new file mode 100644 index 00000000000..7e6ef91ebaf --- /dev/null +++ b/test/language/statements/class/decorator/accessor/public/instance/context-access-set.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-set.case +// - src/decorator/accessors/standard/public/instance/cls-decl.template +/*--- +description: Context access `get` works on all gettable types of values (public acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +class C { + @dec + + accessor element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/accessor/public/instance/context-kind-accessor.js b/test/language/statements/class/decorator/accessor/public/instance/context-kind-accessor.js new file mode 100644 index 00000000000..0b3d16b9b3c --- /dev/null +++ b/test/language/statements/class/decorator/accessor/public/instance/context-kind-accessor.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-accessor.case +// - src/decorator/accessors/standard/public/instance/cls-decl.template +/*--- +description: Context kind is the string "accessor" when decorating a method (public acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "accessor"); +} + + +class C { + @dec + accessor element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/statements/class/decorator/accessor/public/instance/context-name-public.js b/test/language/statements/class/decorator/accessor/public/instance/context-name-public.js new file mode 100644 index 00000000000..47c00abbc76 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/public/instance/context-name-public.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-public.case +// - src/decorator/accessors/standard/public/instance/cls-decl.template +/*--- +description: Context name is correct for all types of public elements (public acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "element"); +} + + +class C { + @dec + accessor element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/statements/class/decorator/accessor/public/instance/context-private-true.js b/test/language/statements/class/decorator/accessor/public/instance/context-private-true.js new file mode 100644 index 00000000000..2d92dcd010e --- /dev/null +++ b/test/language/statements/class/decorator/accessor/public/instance/context-private-true.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-private-true.case +// - src/decorator/accessors/standard/public/instance/cls-decl.template +/*--- +description: Context `private` is false for all types of public elements (public acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.private, false); +} + + +class C { + @dec + accessor element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/statements/class/decorator/accessor/public/instance/context-static-false.js b/test/language/statements/class/decorator/accessor/public/instance/context-static-false.js new file mode 100644 index 00000000000..148580fc5c5 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/public/instance/context-static-false.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-static-false.case +// - src/decorator/accessors/standard/public/instance/cls-decl.template +/*--- +description: Context `static` is false for all types of instance elements (public acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.static, false); +} + + +class C { + @dec + accessor element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/statements/class/decorator/accessor/public/instance/field-and-accessor-init-this.js b/test/language/statements/class/decorator/accessor/public/instance/field-and-accessor-init-this.js new file mode 100644 index 00000000000..cb63e6fbce3 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/public/instance/field-and-accessor-init-this.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/accessors/standard/public/instance/cls-decl.template +/*--- +description: Field initializer `this` value is the instance or the class (public acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +class C { + @dec + + accessor element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/statements/class/decorator/accessor/public/static/accessor-deco-invalid-return-get.js b/test/language/statements/class/decorator/accessor/public/static/accessor-deco-invalid-return-get.js new file mode 100644 index 00000000000..8ecd19b22f1 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/public/static/accessor-deco-invalid-return-get.js @@ -0,0 +1,28 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-invalid-return-get.case +// - src/decorator/accessors/error/public/static/cls-decl.template +/*--- +description: Accessor decorator cannot return invalid getter (public static acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec() { + return { + get: 123 + }; +} + + +function evaluate() { + class C { + @dec + + static accessor element; + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/statements/class/decorator/accessor/public/static/accessor-deco-invalid-return-init.js b/test/language/statements/class/decorator/accessor/public/static/accessor-deco-invalid-return-init.js new file mode 100644 index 00000000000..c91d14a46b3 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/public/static/accessor-deco-invalid-return-init.js @@ -0,0 +1,28 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-invalid-return-init.case +// - src/decorator/accessors/error/public/static/cls-decl.template +/*--- +description: Accessor decorator cannot return invalid init (public static acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec() { + return { + init: 123 + }; +} + + +function evaluate() { + class C { + @dec + + static accessor element; + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/statements/class/decorator/accessor/public/static/accessor-deco-invalid-return-set.js b/test/language/statements/class/decorator/accessor/public/static/accessor-deco-invalid-return-set.js new file mode 100644 index 00000000000..7c89f0b56db --- /dev/null +++ b/test/language/statements/class/decorator/accessor/public/static/accessor-deco-invalid-return-set.js @@ -0,0 +1,28 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-invalid-return-set.case +// - src/decorator/accessors/error/public/static/cls-decl.template +/*--- +description: Accessor decorator cannot return invalid setter (public static acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec() { + return { + set: 123 + }; +} + + +function evaluate() { + class C { + @dec + + static accessor element; + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/statements/class/decorator/accessor/public/static/accessor-deco-invalid-return.js b/test/language/statements/class/decorator/accessor/public/static/accessor-deco-invalid-return.js new file mode 100644 index 00000000000..2791538d910 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/public/static/accessor-deco-invalid-return.js @@ -0,0 +1,26 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-invalid-return.case +// - src/decorator/accessors/error/public/static/cls-decl.template +/*--- +description: Accessor decorator cannot return invalid init (public static acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec() { + return 123; +} + + +function evaluate() { + class C { + @dec + + static accessor element; + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/statements/class/decorator/accessor/public/static/accessor-deco-returns-get.js b/test/language/statements/class/decorator/accessor/public/static/accessor-deco-returns-get.js new file mode 100644 index 00000000000..228818ad912 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/public/static/accessor-deco-returns-get.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-returns-get.case +// - src/decorator/accessors/standard/public/static/cls-decl.template +/*--- +description: Accessor decorator can return a new getter (public static acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec({ get }) { + return { + get() { + assert.sameValue(get.call(this), undefined); + return 123; + } + }; +} + + +class C { + @dec + + static accessor element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 123); diff --git a/test/language/statements/class/decorator/accessor/public/static/accessor-deco-returns-init.js b/test/language/statements/class/decorator/accessor/public/static/accessor-deco-returns-init.js new file mode 100644 index 00000000000..224ef971d07 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/public/static/accessor-deco-returns-init.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-returns-init.case +// - src/decorator/accessors/standard/public/static/cls-decl.template +/*--- +description: Accessor decorator can return a new init (public static acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec() { + return { + init(value) { + assert.sameValue(value, undefined); + return 123; + } + }; +} + + +class C { + @dec + + static accessor element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 123); +classOrInstance.setElement(456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/accessor/public/static/accessor-deco-returns-set.js b/test/language/statements/class/decorator/accessor/public/static/accessor-deco-returns-set.js new file mode 100644 index 00000000000..6e0d11d267e --- /dev/null +++ b/test/language/statements/class/decorator/accessor/public/static/accessor-deco-returns-set.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-deco-returns-set.case +// - src/decorator/accessors/standard/public/static/cls-decl.template +/*--- +description: Accessor decorator can return a new getter (public static acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec({ set }) { + return { + set(value) { + assert.sameValue(value, 123); + set.call(this, 456); + } + }; +} + + +class C { + @dec + + static accessor element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), undefined); +classOrInstance.setElement(123); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/accessor/public/static/context-access-get.js b/test/language/statements/class/decorator/accessor/public/static/context-access-get.js new file mode 100644 index 00000000000..2e14cf8d16a --- /dev/null +++ b/test/language/statements/class/decorator/accessor/public/static/context-access-get.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-get.case +// - src/decorator/accessors/standard/public/static/cls-decl.template +/*--- +description: Context access `get` works on all gettable types of values (public static acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +class C { + @dec + + static accessor element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), access.get(classOrInstance)); diff --git a/test/language/statements/class/decorator/accessor/public/static/context-access-set.js b/test/language/statements/class/decorator/accessor/public/static/context-access-set.js new file mode 100644 index 00000000000..d10f709ddb9 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/public/static/context-access-set.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-set.case +// - src/decorator/accessors/standard/public/static/cls-decl.template +/*--- +description: Context access `get` works on all gettable types of values (public static acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +class C { + @dec + + static accessor element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/accessor/public/static/context-kind-accessor.js b/test/language/statements/class/decorator/accessor/public/static/context-kind-accessor.js new file mode 100644 index 00000000000..66ee6292231 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/public/static/context-kind-accessor.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-accessor.case +// - src/decorator/accessors/standard/public/static/cls-decl.template +/*--- +description: Context kind is the string "accessor" when decorating a method (public static acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "accessor"); +} + + +class C { + @dec + static accessor element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/accessor/public/static/context-name-public.js b/test/language/statements/class/decorator/accessor/public/static/context-name-public.js new file mode 100644 index 00000000000..e773ebf315d --- /dev/null +++ b/test/language/statements/class/decorator/accessor/public/static/context-name-public.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-public.case +// - src/decorator/accessors/standard/public/static/cls-decl.template +/*--- +description: Context name is correct for all types of public elements (public static acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "element"); +} + + +class C { + @dec + static accessor element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/accessor/public/static/context-private-true.js b/test/language/statements/class/decorator/accessor/public/static/context-private-true.js new file mode 100644 index 00000000000..cde7c32495c --- /dev/null +++ b/test/language/statements/class/decorator/accessor/public/static/context-private-true.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-private-true.case +// - src/decorator/accessors/standard/public/static/cls-decl.template +/*--- +description: Context `private` is false for all types of public elements (public static acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.private, false); +} + + +class C { + @dec + static accessor element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/accessor/public/static/context-static-true.js b/test/language/statements/class/decorator/accessor/public/static/context-static-true.js new file mode 100644 index 00000000000..5ee7b2495df --- /dev/null +++ b/test/language/statements/class/decorator/accessor/public/static/context-static-true.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-static-true.case +// - src/decorator/accessors/standard/public/static/cls-decl.template +/*--- +description: Context `static` is false for all types of instance elements (public static acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.static, true); +} + + +class C { + @dec + static accessor element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/accessor/public/static/field-and-accessor-init-this.js b/test/language/statements/class/decorator/accessor/public/static/field-and-accessor-init-this.js new file mode 100644 index 00000000000..4fb7497c8d5 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/public/static/field-and-accessor-init-this.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/accessors/standard/public/static/cls-decl.template +/*--- +description: Field initializer `this` value is the instance or the class (public static acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +class C { + @dec + + static accessor element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/statements/class/decorator/accessor/with-init/private/instance/accessor-with-init-deco-returns-get.js b/test/language/statements/class/decorator/accessor/with-init/private/instance/accessor-with-init-deco-returns-get.js new file mode 100644 index 00000000000..43651e2f260 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/with-init/private/instance/accessor-with-init-deco-returns-get.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-with-init-deco-returns-get.case +// - src/decorator/accessors/with-init/private/instance/cls-decl.template +/*--- +description: Accessor decorator can return a new getter (private accessor with initializer decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec({ get }) { + return { + get() { + assert.sameValue(get.call(this), 123); + return 456; + } + }; +} + + +class C { + @dec + + accessor #element = 123 +; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/accessor/with-init/private/instance/accessor-with-init-deco-returns-init.js b/test/language/statements/class/decorator/accessor/with-init/private/instance/accessor-with-init-deco-returns-init.js new file mode 100644 index 00000000000..874945aa1fd --- /dev/null +++ b/test/language/statements/class/decorator/accessor/with-init/private/instance/accessor-with-init-deco-returns-init.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-with-init-deco-returns-init.case +// - src/decorator/accessors/with-init/private/instance/cls-decl.template +/*--- +description: Accessor decorator can return a new init that chains with default initializer (private accessor with initializer decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec({ get, set }) { + return { + init(value) { + assert.sameValue(value, 123); + return 456; + } + }; +} + + +class C { + @dec + + accessor #element = 123 +; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 456); +classOrInstance.setElement(789); +assert.sameValue(classOrInstance.getElement(), 789); diff --git a/test/language/statements/class/decorator/accessor/with-init/private/instance/accessor-with-init-deco-returns-set.js b/test/language/statements/class/decorator/accessor/with-init/private/instance/accessor-with-init-deco-returns-set.js new file mode 100644 index 00000000000..0afd65a813c --- /dev/null +++ b/test/language/statements/class/decorator/accessor/with-init/private/instance/accessor-with-init-deco-returns-set.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-with-init-deco-returns-set.case +// - src/decorator/accessors/with-init/private/instance/cls-decl.template +/*--- +description: Accessor decorator can return a new setter when initializer is present (private accessor with initializer decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec({ set }) { + return { + set(value) { + assert.sameValue(value, 456); + set.call(this, 789); + } + }; +} + + +class C { + @dec + + accessor #element = 123 +; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 123); +classOrInstance.setElement(456); +assert.sameValue(classOrInstance.getElement(), 789); diff --git a/test/language/statements/class/decorator/accessor/with-init/private/instance/context-access-get.js b/test/language/statements/class/decorator/accessor/with-init/private/instance/context-access-get.js new file mode 100644 index 00000000000..9f3ef5febe8 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/with-init/private/instance/context-access-get.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-get.case +// - src/decorator/accessors/with-init/private/instance/cls-decl.template +/*--- +description: Context access `get` works on all gettable types of values (private accessor with initializer decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +class C { + @dec + + accessor #element = 123 +; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), access.get(classOrInstance)); diff --git a/test/language/statements/class/decorator/accessor/with-init/private/instance/context-access-set.js b/test/language/statements/class/decorator/accessor/with-init/private/instance/context-access-set.js new file mode 100644 index 00000000000..99c56dacb38 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/with-init/private/instance/context-access-set.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-set.case +// - src/decorator/accessors/with-init/private/instance/cls-decl.template +/*--- +description: Context access `get` works on all gettable types of values (private accessor with initializer decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +class C { + @dec + + accessor #element = 123 +; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/accessor/with-init/private/instance/decorator-order-application-field-and-accessor.js b/test/language/statements/class/decorator/accessor/with-init/private/instance/decorator-order-application-field-and-accessor.js new file mode 100644 index 00000000000..b2558df5719 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/with-init/private/instance/decorator-order-application-field-and-accessor.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-order-application-field-and-accessor.case +// - src/decorator/accessors/with-init/private/instance/cls-decl.template +/*--- +description: Order of decorator application for elements with initializers (private accessor with initializer decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +var ord = []; + +function pushOrd(applyOrd, initOrd, extraInitOrd) { + return (value, context) => { + ord.push(applyOrd); + context.addInitializer(() => ord.push(extraInitOrd)); + + if (context.kind === 'field') { + return () => ord.push(initOrd); + } else { + return { + init() { + ord.push(initOrd); + } + } + } + } +} + + +class C { + @pushOrd(1, 3, 6) + @pushOrd(0, 4, 5) + + accessor #element = ord.push(2) +; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(ord.length, 7); +ord.forEach(assert.sameValue); diff --git a/test/language/statements/class/decorator/accessor/with-init/private/instance/field-and-accessor-init-this.js b/test/language/statements/class/decorator/accessor/with-init/private/instance/field-and-accessor-init-this.js new file mode 100644 index 00000000000..6493d1cab09 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/with-init/private/instance/field-and-accessor-init-this.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/accessors/with-init/private/instance/cls-decl.template +/*--- +description: Field initializer `this` value is the instance or the class (private accessor with initializer decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +class C { + @dec + + accessor #element = savedThisValues.push(this); +; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/statements/class/decorator/accessor/with-init/private/static/accessor-with-init-deco-returns-get.js b/test/language/statements/class/decorator/accessor/with-init/private/static/accessor-with-init-deco-returns-get.js new file mode 100644 index 00000000000..2bedf5ef3d6 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/with-init/private/static/accessor-with-init-deco-returns-get.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-with-init-deco-returns-get.case +// - src/decorator/accessors/with-init/private/static/cls-decl.template +/*--- +description: Accessor decorator can return a new getter (private static with initializer acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec({ get }) { + return { + get() { + assert.sameValue(get.call(this), 123); + return 456; + } + }; +} + + +class C { + @dec + + static accessor #element = 123 +; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/accessor/with-init/private/static/accessor-with-init-deco-returns-init.js b/test/language/statements/class/decorator/accessor/with-init/private/static/accessor-with-init-deco-returns-init.js new file mode 100644 index 00000000000..3dbe0f12d44 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/with-init/private/static/accessor-with-init-deco-returns-init.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-with-init-deco-returns-init.case +// - src/decorator/accessors/with-init/private/static/cls-decl.template +/*--- +description: Accessor decorator can return a new init that chains with default initializer (private static with initializer acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec({ get, set }) { + return { + init(value) { + assert.sameValue(value, 123); + return 456; + } + }; +} + + +class C { + @dec + + static accessor #element = 123 +; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 456); +classOrInstance.setElement(789); +assert.sameValue(classOrInstance.getElement(), 789); diff --git a/test/language/statements/class/decorator/accessor/with-init/private/static/accessor-with-init-deco-returns-set.js b/test/language/statements/class/decorator/accessor/with-init/private/static/accessor-with-init-deco-returns-set.js new file mode 100644 index 00000000000..d4d88472990 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/with-init/private/static/accessor-with-init-deco-returns-set.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-with-init-deco-returns-set.case +// - src/decorator/accessors/with-init/private/static/cls-decl.template +/*--- +description: Accessor decorator can return a new setter when initializer is present (private static with initializer acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec({ set }) { + return { + set(value) { + assert.sameValue(value, 456); + set.call(this, 789); + } + }; +} + + +class C { + @dec + + static accessor #element = 123 +; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 123); +classOrInstance.setElement(456); +assert.sameValue(classOrInstance.getElement(), 789); diff --git a/test/language/statements/class/decorator/accessor/with-init/private/static/context-access-get.js b/test/language/statements/class/decorator/accessor/with-init/private/static/context-access-get.js new file mode 100644 index 00000000000..bf53e58820b --- /dev/null +++ b/test/language/statements/class/decorator/accessor/with-init/private/static/context-access-get.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-get.case +// - src/decorator/accessors/with-init/private/static/cls-decl.template +/*--- +description: Context access `get` works on all gettable types of values (private static with initializer acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +class C { + @dec + + static accessor #element = 123 +; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), access.get(classOrInstance)); diff --git a/test/language/statements/class/decorator/accessor/with-init/private/static/context-access-set.js b/test/language/statements/class/decorator/accessor/with-init/private/static/context-access-set.js new file mode 100644 index 00000000000..2e79aa66fd8 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/with-init/private/static/context-access-set.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-set.case +// - src/decorator/accessors/with-init/private/static/cls-decl.template +/*--- +description: Context access `get` works on all gettable types of values (private static with initializer acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +class C { + @dec + + static accessor #element = 123 +; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/accessor/with-init/private/static/decorator-order-application-field-and-accessor.js b/test/language/statements/class/decorator/accessor/with-init/private/static/decorator-order-application-field-and-accessor.js new file mode 100644 index 00000000000..8029aecbc50 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/with-init/private/static/decorator-order-application-field-and-accessor.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-order-application-field-and-accessor.case +// - src/decorator/accessors/with-init/private/static/cls-decl.template +/*--- +description: Order of decorator application for elements with initializers (private static with initializer acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +var ord = []; + +function pushOrd(applyOrd, initOrd, extraInitOrd) { + return (value, context) => { + ord.push(applyOrd); + context.addInitializer(() => ord.push(extraInitOrd)); + + if (context.kind === 'field') { + return () => ord.push(initOrd); + } else { + return { + init() { + ord.push(initOrd); + } + } + } + } +} + + +class C { + @pushOrd(1, 3, 6) + @pushOrd(0, 4, 5) + + static accessor #element = ord.push(2) +; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(ord.length, 7); +ord.forEach(assert.sameValue); diff --git a/test/language/statements/class/decorator/accessor/with-init/private/static/field-and-accessor-init-this.js b/test/language/statements/class/decorator/accessor/with-init/private/static/field-and-accessor-init-this.js new file mode 100644 index 00000000000..746d715a923 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/with-init/private/static/field-and-accessor-init-this.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/accessors/with-init/private/static/cls-decl.template +/*--- +description: Field initializer `this` value is the instance or the class (private static with initializer acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +class C { + @dec + + static accessor #element = savedThisValues.push(this); +; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/statements/class/decorator/accessor/with-init/public/instance/accessor-with-init-deco-returns-get.js b/test/language/statements/class/decorator/accessor/with-init/public/instance/accessor-with-init-deco-returns-get.js new file mode 100644 index 00000000000..b1410064e9c --- /dev/null +++ b/test/language/statements/class/decorator/accessor/with-init/public/instance/accessor-with-init-deco-returns-get.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-with-init-deco-returns-get.case +// - src/decorator/accessors/with-init/public/instance/cls-decl.template +/*--- +description: Accessor decorator can return a new getter (public accessor with initializer decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec({ get }) { + return { + get() { + assert.sameValue(get.call(this), 123); + return 456; + } + }; +} + + +class C { + @dec + + accessor element = 123 +; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/accessor/with-init/public/instance/accessor-with-init-deco-returns-init.js b/test/language/statements/class/decorator/accessor/with-init/public/instance/accessor-with-init-deco-returns-init.js new file mode 100644 index 00000000000..148500b1dd6 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/with-init/public/instance/accessor-with-init-deco-returns-init.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-with-init-deco-returns-init.case +// - src/decorator/accessors/with-init/public/instance/cls-decl.template +/*--- +description: Accessor decorator can return a new init that chains with default initializer (public accessor with initializer decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec({ get, set }) { + return { + init(value) { + assert.sameValue(value, 123); + return 456; + } + }; +} + + +class C { + @dec + + accessor element = 123 +; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 456); +classOrInstance.setElement(789); +assert.sameValue(classOrInstance.getElement(), 789); diff --git a/test/language/statements/class/decorator/accessor/with-init/public/instance/accessor-with-init-deco-returns-set.js b/test/language/statements/class/decorator/accessor/with-init/public/instance/accessor-with-init-deco-returns-set.js new file mode 100644 index 00000000000..25f003ce65e --- /dev/null +++ b/test/language/statements/class/decorator/accessor/with-init/public/instance/accessor-with-init-deco-returns-set.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-with-init-deco-returns-set.case +// - src/decorator/accessors/with-init/public/instance/cls-decl.template +/*--- +description: Accessor decorator can return a new setter when initializer is present (public accessor with initializer decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec({ set }) { + return { + set(value) { + assert.sameValue(value, 456); + set.call(this, 789); + } + }; +} + + +class C { + @dec + + accessor element = 123 +; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 123); +classOrInstance.setElement(456); +assert.sameValue(classOrInstance.getElement(), 789); diff --git a/test/language/statements/class/decorator/accessor/with-init/public/instance/context-access-get.js b/test/language/statements/class/decorator/accessor/with-init/public/instance/context-access-get.js new file mode 100644 index 00000000000..4a9c82d7334 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/with-init/public/instance/context-access-get.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-get.case +// - src/decorator/accessors/with-init/public/instance/cls-decl.template +/*--- +description: Context access `get` works on all gettable types of values (public accessor with initializer decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +class C { + @dec + + accessor element = 123 +; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), access.get(classOrInstance)); diff --git a/test/language/statements/class/decorator/accessor/with-init/public/instance/context-access-set.js b/test/language/statements/class/decorator/accessor/with-init/public/instance/context-access-set.js new file mode 100644 index 00000000000..c0d4f541672 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/with-init/public/instance/context-access-set.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-set.case +// - src/decorator/accessors/with-init/public/instance/cls-decl.template +/*--- +description: Context access `get` works on all gettable types of values (public accessor with initializer decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +class C { + @dec + + accessor element = 123 +; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/accessor/with-init/public/instance/decorator-order-application-field-and-accessor.js b/test/language/statements/class/decorator/accessor/with-init/public/instance/decorator-order-application-field-and-accessor.js new file mode 100644 index 00000000000..d4e383cd24d --- /dev/null +++ b/test/language/statements/class/decorator/accessor/with-init/public/instance/decorator-order-application-field-and-accessor.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-order-application-field-and-accessor.case +// - src/decorator/accessors/with-init/public/instance/cls-decl.template +/*--- +description: Order of decorator application for elements with initializers (public accessor with initializer decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +var ord = []; + +function pushOrd(applyOrd, initOrd, extraInitOrd) { + return (value, context) => { + ord.push(applyOrd); + context.addInitializer(() => ord.push(extraInitOrd)); + + if (context.kind === 'field') { + return () => ord.push(initOrd); + } else { + return { + init() { + ord.push(initOrd); + } + } + } + } +} + + +class C { + @pushOrd(1, 3, 6) + @pushOrd(0, 4, 5) + + accessor element = ord.push(2) +; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(ord.length, 7); +ord.forEach(assert.sameValue); diff --git a/test/language/statements/class/decorator/accessor/with-init/public/instance/field-and-accessor-init-this.js b/test/language/statements/class/decorator/accessor/with-init/public/instance/field-and-accessor-init-this.js new file mode 100644 index 00000000000..6270b76b5a8 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/with-init/public/instance/field-and-accessor-init-this.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/accessors/with-init/public/instance/cls-decl.template +/*--- +description: Field initializer `this` value is the instance or the class (public accessor with initializer decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +class C { + @dec + + accessor element = savedThisValues.push(this); +; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/statements/class/decorator/accessor/with-init/public/static/accessor-with-init-deco-returns-get.js b/test/language/statements/class/decorator/accessor/with-init/public/static/accessor-with-init-deco-returns-get.js new file mode 100644 index 00000000000..8d334db79de --- /dev/null +++ b/test/language/statements/class/decorator/accessor/with-init/public/static/accessor-with-init-deco-returns-get.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-with-init-deco-returns-get.case +// - src/decorator/accessors/with-init/public/static/cls-decl.template +/*--- +description: Accessor decorator can return a new getter (public static with initializer acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec({ get }) { + return { + get() { + assert.sameValue(get.call(this), 123); + return 456; + } + }; +} + + +class C { + @dec + + static accessor element = 123 +; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/accessor/with-init/public/static/accessor-with-init-deco-returns-init.js b/test/language/statements/class/decorator/accessor/with-init/public/static/accessor-with-init-deco-returns-init.js new file mode 100644 index 00000000000..05669ab627f --- /dev/null +++ b/test/language/statements/class/decorator/accessor/with-init/public/static/accessor-with-init-deco-returns-init.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-with-init-deco-returns-init.case +// - src/decorator/accessors/with-init/public/static/cls-decl.template +/*--- +description: Accessor decorator can return a new init that chains with default initializer (public static with initializer acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec({ get, set }) { + return { + init(value) { + assert.sameValue(value, 123); + return 456; + } + }; +} + + +class C { + @dec + + static accessor element = 123 +; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 456); +classOrInstance.setElement(789); +assert.sameValue(classOrInstance.getElement(), 789); diff --git a/test/language/statements/class/decorator/accessor/with-init/public/static/accessor-with-init-deco-returns-set.js b/test/language/statements/class/decorator/accessor/with-init/public/static/accessor-with-init-deco-returns-set.js new file mode 100644 index 00000000000..239c2bd0188 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/with-init/public/static/accessor-with-init-deco-returns-set.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/accessor-with-init-deco-returns-set.case +// - src/decorator/accessors/with-init/public/static/cls-decl.template +/*--- +description: Accessor decorator can return a new setter when initializer is present (public static with initializer acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec({ set }) { + return { + set(value) { + assert.sameValue(value, 456); + set.call(this, 789); + } + }; +} + + +class C { + @dec + + static accessor element = 123 +; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 123); +classOrInstance.setElement(456); +assert.sameValue(classOrInstance.getElement(), 789); diff --git a/test/language/statements/class/decorator/accessor/with-init/public/static/context-access-get.js b/test/language/statements/class/decorator/accessor/with-init/public/static/context-access-get.js new file mode 100644 index 00000000000..b3e44d60958 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/with-init/public/static/context-access-get.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-get.case +// - src/decorator/accessors/with-init/public/static/cls-decl.template +/*--- +description: Context access `get` works on all gettable types of values (public static with initializer acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +class C { + @dec + + static accessor element = 123 +; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), access.get(classOrInstance)); diff --git a/test/language/statements/class/decorator/accessor/with-init/public/static/context-access-set.js b/test/language/statements/class/decorator/accessor/with-init/public/static/context-access-set.js new file mode 100644 index 00000000000..9f9638f013b --- /dev/null +++ b/test/language/statements/class/decorator/accessor/with-init/public/static/context-access-set.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-set.case +// - src/decorator/accessors/with-init/public/static/cls-decl.template +/*--- +description: Context access `get` works on all gettable types of values (public static with initializer acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +class C { + @dec + + static accessor element = 123 +; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/accessor/with-init/public/static/decorator-order-application-field-and-accessor.js b/test/language/statements/class/decorator/accessor/with-init/public/static/decorator-order-application-field-and-accessor.js new file mode 100644 index 00000000000..72a86f7257e --- /dev/null +++ b/test/language/statements/class/decorator/accessor/with-init/public/static/decorator-order-application-field-and-accessor.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-order-application-field-and-accessor.case +// - src/decorator/accessors/with-init/public/static/cls-decl.template +/*--- +description: Order of decorator application for elements with initializers (public static with initializer acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +var ord = []; + +function pushOrd(applyOrd, initOrd, extraInitOrd) { + return (value, context) => { + ord.push(applyOrd); + context.addInitializer(() => ord.push(extraInitOrd)); + + if (context.kind === 'field') { + return () => ord.push(initOrd); + } else { + return { + init() { + ord.push(initOrd); + } + } + } + } +} + + +class C { + @pushOrd(1, 3, 6) + @pushOrd(0, 4, 5) + + static accessor element = ord.push(2) +; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(ord.length, 7); +ord.forEach(assert.sameValue); diff --git a/test/language/statements/class/decorator/accessor/with-init/public/static/field-and-accessor-init-this.js b/test/language/statements/class/decorator/accessor/with-init/public/static/field-and-accessor-init-this.js new file mode 100644 index 00000000000..c38b881726a --- /dev/null +++ b/test/language/statements/class/decorator/accessor/with-init/public/static/field-and-accessor-init-this.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/accessors/with-init/public/static/cls-decl.template +/*--- +description: Field initializer `this` value is the instance or the class (public static with initializer acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +class C { + @dec + + static accessor element = savedThisValues.push(this); +; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/statements/class/decorator/class/class-deco-rebinds-identifier.js b/test/language/statements/class/decorator/class/class-deco-rebinds-identifier.js new file mode 100644 index 00000000000..1b84736ebbd --- /dev/null +++ b/test/language/statements/class/decorator/class/class-deco-rebinds-identifier.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/class-deco-rebinds-identifier.case +// - src/decorator/class/standard/cls-decl.template +/*--- +description: Class decorator return value is rebound before static fields are run (decorator usage in a class declaration) +esid: prod-ClassDeclaration +features: [decorators, class] +flags: [generated] +---*/ + + +var originalClass; +var subClass; + +function dec(C, context) { + originalClass = C; + subClass = class D extends C {} + + return subClass; +} + + +@dec + +class C { + static foo = assert(C === subClass, 'class identifier was rebound'); + +} + +var c = new C(); + +assert.sameValue(C, subClass); +assert(c instanceof originalClass, 'new class is subclass of old class'); diff --git a/test/language/statements/class/decorator/class/class-deco-returns-class.js b/test/language/statements/class/decorator/class/class-deco-returns-class.js new file mode 100644 index 00000000000..a7bbeed79d1 --- /dev/null +++ b/test/language/statements/class/decorator/class/class-deco-returns-class.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/class-deco-returns-class.case +// - src/decorator/class/standard/cls-decl.template +/*--- +description: Class decorator can return a new class (decorator usage in a class declaration) +esid: prod-ClassDeclaration +features: [decorators, class] +flags: [generated] +---*/ + + +var originalClass; +var newClass; + +function dec(C, context) { + originalClass = C; + newClass = class D { + static foo() { + return 123; + } + }; + + return newClass; +} + + +@dec + +class C { + +} + +assert.sameValue(C, newClass); +assert(!(C instanceof originalClass), 'new class is not a subclass of old class'); +assert.sameValue(C.foo(), 123); + diff --git a/test/language/statements/class/decorator/class/class-deco-returns-function.js b/test/language/statements/class/decorator/class/class-deco-returns-function.js new file mode 100644 index 00000000000..36981021584 --- /dev/null +++ b/test/language/statements/class/decorator/class/class-deco-returns-function.js @@ -0,0 +1,26 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/class-deco-returns-function.case +// - src/decorator/class/standard/cls-decl.template +/*--- +description: Class decorator can return a standard function (decorator usage in a class declaration) +esid: prod-ClassDeclaration +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(C, context) { + return function() { + return 123; + }; +} + + +@dec + +class C { + +} + +assert.sameValue(C(), 123); + diff --git a/test/language/statements/class/decorator/class/class-deco-returns-proxy.js b/test/language/statements/class/decorator/class/class-deco-returns-proxy.js new file mode 100644 index 00000000000..a81b700c9aa --- /dev/null +++ b/test/language/statements/class/decorator/class/class-deco-returns-proxy.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/class-deco-returns-proxy.case +// - src/decorator/class/standard/cls-decl.template +/*--- +description: Class decorator can return a Proxy (decorator usage in a class declaration) +esid: prod-ClassDeclaration +features: [decorators, Proxy, class] +flags: [generated] +---*/ + + +var originalClass; +var subClass; + +function dec(C, context) { + originalClass = C; + + return new Proxy(C, { + construct() { + return 123; + } + }); +} + + +@dec + +class C { + +} + +assert(C !== originalClass, 'values are not the same'); +assert(C instanceof originalClass, 'value is instance of class'); +assert.sameValue(new C(), 123); diff --git a/test/language/statements/class/decorator/class/class-deco-returns-subclass.js b/test/language/statements/class/decorator/class/class-deco-returns-subclass.js new file mode 100644 index 00000000000..4169f7c314e --- /dev/null +++ b/test/language/statements/class/decorator/class/class-deco-returns-subclass.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/class-deco-returns-subclass.case +// - src/decorator/class/standard/cls-decl.template +/*--- +description: Class decorator can return a new class (decorator usage in a class declaration) +esid: prod-ClassDeclaration +features: [decorators, class] +flags: [generated] +---*/ + + +var originalClass; +var subClass; + +function dec(C, context) { + originalClass = C; + subClass = class D extends C { + static foo() { + return 123; + } + }; + + return subClass; +} + + +@dec + +class C { + +} + +var c = new C(); + +assert.sameValue(C, subClass); +assert(c instanceof originalClass, 'new class is subclass of old class'); +assert.sameValue(C.foo(), 123); diff --git a/test/language/statements/class/decorator/class/context-kind-class.js b/test/language/statements/class/decorator/class/context-kind-class.js new file mode 100644 index 00000000000..c3053516362 --- /dev/null +++ b/test/language/statements/class/decorator/class/context-kind-class.js @@ -0,0 +1,22 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-class.case +// - src/decorator/class/standard/cls-decl.template +/*--- +description: Context kind is the string "class" when decorating a method (decorator usage in a class declaration) +esid: prod-ClassDeclaration +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "class"); +} + + +@dec +class C { + +} + + diff --git a/test/language/statements/class/decorator/class/context-name-class.js b/test/language/statements/class/decorator/class/context-name-class.js new file mode 100644 index 00000000000..131aa5928fe --- /dev/null +++ b/test/language/statements/class/decorator/class/context-name-class.js @@ -0,0 +1,22 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-class.case +// - src/decorator/class/standard/cls-decl.template +/*--- +description: Name of the class is correct on the context object (decorator usage in a class declaration) +esid: prod-ClassDeclaration +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "C"); +} + + +@dec +class C { + +} + + diff --git a/test/language/statements/class/decorator/class/decorator-order-application-method-and-class.js b/test/language/statements/class/decorator/class/decorator-order-application-method-and-class.js new file mode 100644 index 00000000000..a51642500fe --- /dev/null +++ b/test/language/statements/class/decorator/class/decorator-order-application-method-and-class.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-order-application-method-and-class.case +// - src/decorator/class/standard/cls-decl.template +/*--- +description: Order of decorator application for elements without initializers (decorator usage in a class declaration) +esid: prod-ClassDeclaration +features: [decorators, class] +flags: [generated] +---*/ + + +var ord = []; + +function pushOrd(applyOrd, extraInitOrd) { + return (value, context) => { + ord.push(applyOrd); + context.addInitializer(() => ord.push(extraInitOrd)); + } +} + + +@pushOrd(1, 3) +@pushOrd(0, 2) + +class C { + +} + +assert.sameValue(ord.length, 4); +ord.forEach(assert.sameValue); diff --git a/test/language/statements/class/decorator/class/decorator-order-phases-1-pre-definition.js b/test/language/statements/class/decorator/class/decorator-order-phases-1-pre-definition.js new file mode 100644 index 00000000000..df57415587c --- /dev/null +++ b/test/language/statements/class/decorator/class/decorator-order-phases-1-pre-definition.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-order-phases-1-pre-definition.case +// - src/decorator/class/standard/cls-decl.template +/*--- +description: Class pre-definition evaluation phase order (decorator usage in a class declaration) +esid: prod-ClassDeclaration +features: [decorators, class] +flags: [generated] +info: | + In the pre-definition phase, all expressions that are part of the class + definition itself are evaluated to get the final concrete values that are + needed to fully evaluate the class itself. This includes: + + - Dynamic element names + - Decorator expressions (e.g. `@foo()`, which calls a function and returns a + decorator) + + These are evaluated in lexical order from top to bottom. + +---*/ + + +var ord = []; + +// For dynamic element name evaluation order +function dynamicName(name, order) { + ord.push(order); + return name; +} + +function pushOrd(evalOrd) { + ord.push(evalOrd); + + return () => { + // do nothing + } +} + +ord.push(0); + + +@pushOrd(1) + +class C { + @pushOrd(2) + [dynamicName('a', 3)]() {} + + @pushOrd(4) + #b() {} + + @pushOrd(5) + static [dynamicName('c', 6)]() {} + + @pushOrd(7) + static #d() {} + + @pushOrd(8) + [dynamicName('e', 9)] = 123; + + @pushOrd(10) + #f = 123; + +} + +ord.push(11); + +new C(); + +ord.push(12); + +assert.sameValue(ord.length, 13); +ord.forEach(assert.sameValue); diff --git a/test/language/statements/class/decorator/class/decorator-order-phases-2-application.js b/test/language/statements/class/decorator/class/decorator-order-phases-2-application.js new file mode 100644 index 00000000000..52a2db3551a --- /dev/null +++ b/test/language/statements/class/decorator/class/decorator-order-phases-2-application.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-order-phases-2-application.case +// - src/decorator/class/standard/cls-decl.template +/*--- +description: Class definition decorator application order (decorator usage in a class declaration) +esid: prod-ClassDeclaration +features: [decorators, class] +flags: [generated] +info: | + In the application phase, decorators are applied to each element in the + following order: + + 1. Static methods + 2. Instance methods + 3. Static fields + 4. Instance fields + 5. Class + + Within each group, decorators are applied to each _element_ in lexical order, + from top to bottom (note: This refers to ordering _between_ elements. Within a + single element definition, decorators are applied in reverse lexical order.) + As each method is defined, the method itself is assigned to the prototype or + class definition. + +---*/ + + +var ord = []; + +function pushOrd(applyOrd) { + return () => { + ord.push(applyOrd); + } +} + +ord.push(0); + + + +@pushOrd(9) + + +class C { + @pushOrd(8) + a = 123; + + @pushOrd(4) + b() {} + + @pushOrd(1) + static accessor c = 123; + + @pushOrd(2) + static get d() {} + + + @pushOrd(5) + accessor e = 123; + + @pushOrd(6) + get f() {} + + @pushOrd(7) + static g = 123; + + @pushOrd(3) + static h() {} + + +} + +ord.push(10); + +new C(); + +ord.push(11); + +assert.sameValue(ord.length, 12); +ord.forEach(assert.sameValue); diff --git a/test/language/statements/class/decorator/class/decorator-order-phases-3-init-static.js b/test/language/statements/class/decorator/class/decorator-order-phases-3-init-static.js new file mode 100644 index 00000000000..7572cabec87 --- /dev/null +++ b/test/language/statements/class/decorator/class/decorator-order-phases-3-init-static.js @@ -0,0 +1,102 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-order-phases-3-init-static.case +// - src/decorator/class/standard/cls-decl.template +/*--- +description: Class definition static initialization order (decorator usage in a class declaration) +esid: prod-ClassDeclaration +features: [decorators, class] +flags: [generated] +info: | + In the static initialization phase, the class definition is initialized in the + following order: + + 1. Static method extra-initializers are run, finalizing static method + definition. + 2. Static fields and blocks are evaluated and assigned in lexical order. For + each field, extra-initializers are run for that field immediately after + assignment. + 3. Class extra-initializers are run, finalizing the class definition. + + After this, the class is fully defined. + +---*/ + + +var ord = []; + +// For dynamic element name evaluation order +function dynamicName(name, order) { + ord.push(order); + return name; +} + +function pushOrd(initOrd, extraInitOrd) { + return (value, context) => { + if (context.kind === 'field') { + context.addInitializer(() => ord.push(extraInitOrd)); + + return () => ord.push(initOrd); + } else if (context.kind === 'accessor') { + context.addInitializer(() => ord.push(extraInitOrd)); + + return { + init() { + ord.push(initOrd); + } + } + } else { + context.addInitializer(() => ord.push(initOrd)); + } + } +} + +ord.push(0); + + + +@pushOrd(12) + + +class C { + static { + ord.push(3); + } + + + @pushOrd(1) + static a() {} + + @pushOrd(5, 6) + static accessor b = ord.push(4); + + e = ord.push(14); + + + static { + ord.push(7); + } + + + accessor e = ord.push(15); + + @pushOrd(2) + static get c() {} + + @pushOrd(9, 10) + static d = ord.push(8); + + + static { + ord.push(11); + } + +} + +ord.push(13); + +new C(); + +ord.push(16); + +assert.sameValue(ord.length, 17); +ord.forEach(assert.sameValue); diff --git a/test/language/statements/class/decorator/class/decorator-order-phases.js b/test/language/statements/class/decorator/class/decorator-order-phases.js new file mode 100644 index 00000000000..854f0729004 --- /dev/null +++ b/test/language/statements/class/decorator/class/decorator-order-phases.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-order-phases.case +// - src/decorator/class/standard/cls-decl.template +/*--- +description: Order of decorators (decorator usage in a class declaration) +esid: prod-ClassDeclaration +features: [decorators, class] +flags: [generated] +info: | + With decorators, definition and instantiation happens in 3 main observable + phases: + + 1. Pre-definition: + + Class key expressions and decorator expressions are evaluated, giving us + all the concrete values that are needed to fully evaluate the class + definition. + + 2. Decorator application and method assignment: + + Decorators are applied to each class element, and methods are + assigned to the class prototype (or class for static methods). Class + decorators are run after all other decorators, and the class identifier + is rebound to the final return value. + + 3. Static initialization: + + Static method extra initializers are run, then static blocks and fields + are initialized and assigned and field extra initializers are run. + Finally, class extra initializers are run. The class is now fully + defined. + + 4. Class instantiation: + + The last phases instantiation, when an instance is created. Instance + method and field extra initializers are run. + + This test compares the relative ordering of these phases, and other tests + check the ordering within each phase + +---*/ + + +var ord = []; + +function pushOrd(evalOrd, applyOrd, initOrd) { + ord.push(evalOrd); + + return (value, context) => { + ord.push(applyOrd); + + context.addInitializer(() => ord.push(initOrd)); + } +} + +ord.push(0); + + +@pushOrd(1, 6, 7) + +class C { + @pushOrd(2, 4, 9) + a() {} + + @pushOrd(3, 5, 10) + b() {} + +} + +ord.push(8); + +new C(); + +assert.sameValue(ord.length, 11); +ord.forEach(assert.sameValue); diff --git a/test/language/statements/class/decorator/class/error/class-deco-invalid-return-arrow.js b/test/language/statements/class/decorator/class/error/class-deco-invalid-return-arrow.js new file mode 100644 index 00000000000..1ae623cc2f3 --- /dev/null +++ b/test/language/statements/class/decorator/class/error/class-deco-invalid-return-arrow.js @@ -0,0 +1,23 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/class-deco-invalid-return-arrow.case +// - src/decorator/class/error/cls-decl.template +/*--- +description: Class decorator cannot return non-newable function (arrow) (class decorator evaluation error in class declaration) +esid: prod-ClassDeclaration +features: [decorators, class] +flags: [generated] +---*/ + + +function dec() { + return () => {} +} + + +function evaluate() { + @dec + + class C {} +} + +assert.throws(TypeError, evaluate); diff --git a/test/language/statements/class/decorator/class/error/class-deco-invalid-return-primitive.js b/test/language/statements/class/decorator/class/error/class-deco-invalid-return-primitive.js new file mode 100644 index 00000000000..413e4397f86 --- /dev/null +++ b/test/language/statements/class/decorator/class/error/class-deco-invalid-return-primitive.js @@ -0,0 +1,23 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/class-deco-invalid-return-primitive.case +// - src/decorator/class/error/cls-decl.template +/*--- +description: Class decorator cannot return a random non-newable value (class decorator evaluation error in class declaration) +esid: prod-ClassDeclaration +features: [decorators, class] +flags: [generated] +---*/ + + +function dec() { + return 123; +} + + +function evaluate() { + @dec + + class C {} +} + +assert.throws(TypeError, evaluate); diff --git a/test/language/statements/class/decorator/class/with-super-class/decorator-order-phases-4-init-instance.js b/test/language/statements/class/decorator/class/with-super-class/decorator-order-phases-4-init-instance.js new file mode 100644 index 00000000000..d155ed605cc --- /dev/null +++ b/test/language/statements/class/decorator/class/with-super-class/decorator-order-phases-4-init-instance.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-order-phases-4-init-instance.case +// - src/decorator/class/with-super-class/cls-decl.template +/*--- +description: Class instance creation order (decorator usage in a class declaration) +esid: prod-ClassDeclaration +features: [decorators, class] +flags: [generated] +info: | + Class instances are created in the following order: + + 1. The class constructor begins evaluating + 2. Super class is fully initialized (e.g. `super()` is called) + 3. Prototype method extra initializers are run, finalizing method definitions + 4. Instance field/accessors are assigned, and field/accessor extra + initializers run immediately after each field/accessor assignment. + +---*/ + + +var ord = []; + +// For dynamic element name evaluation order +function dynamicName(name, order) { + ord.push(order); + return name; +} + +function pushOrd(initOrd, extraInitOrd) { + return (value, context) => { + if (context.kind === 'field') { + context.addInitializer(() => ord.push(extraInitOrd)); + + return () => ord.push(initOrd); + } else if (context.kind === 'accessor') { + context.addInitializer(() => ord.push(extraInitOrd)); + + return { + init() { + ord.push(initOrd); + } + } + } else { + context.addInitializer(() => ord.push(initOrd)); + } + } +} + +ord.push(0); + + + +class B {} + + +class C extends B { + constructor() { + ord.push(2); + super(); + ord.push(13); + } + + a = ord.push(5); + + @pushOrd(3) + b() {} + + @pushOrd(7, 8) + accessor c = ord.push(6); + + @pushOrd(4) + get d() {} + + accessor f = ord.push(9); + + @pushOrd(11, 12) + e = ord.push(10); + + +} + +ord.push(1); + +new C(); + +ord.push(14); + +assert.sameValue(ord.length, 15); +ord.forEach(assert.sameValue); diff --git a/test/language/statements/class/decorator/field/error/private/instance/field-deco-invalid-return.js b/test/language/statements/class/decorator/field/error/private/instance/field-deco-invalid-return.js new file mode 100644 index 00000000000..87f0d3a7c09 --- /dev/null +++ b/test/language/statements/class/decorator/field/error/private/instance/field-deco-invalid-return.js @@ -0,0 +1,25 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-deco-invalid-return.case +// - src/decorator/fields/error/private/instance/cls-decl.template +/*--- +description: Decorator can't return an invalid value (private field decorator evaluation error in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec(value) { + return 123; +} + + +function evaluate() { + class C { + @dec + + #element; + } +} + +assert.throws(TypeError, evaluate); diff --git a/test/language/statements/class/decorator/field/error/private/static/field-deco-invalid-return.js b/test/language/statements/class/decorator/field/error/private/static/field-deco-invalid-return.js new file mode 100644 index 00000000000..13203cb16d8 --- /dev/null +++ b/test/language/statements/class/decorator/field/error/private/static/field-deco-invalid-return.js @@ -0,0 +1,26 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-deco-invalid-return.case +// - src/decorator/fields/error/private/static/cls-decl.template +/*--- +description: Decorator can't return an invalid value (private static field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec(value) { + return 123; +} + + +function evaluate() { + class C { + @dec + + static #element; + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/statements/class/decorator/field/error/public/instance/field-deco-invalid-return.js b/test/language/statements/class/decorator/field/error/public/instance/field-deco-invalid-return.js new file mode 100644 index 00000000000..72c37856504 --- /dev/null +++ b/test/language/statements/class/decorator/field/error/public/instance/field-deco-invalid-return.js @@ -0,0 +1,26 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-deco-invalid-return.case +// - src/decorator/fields/error/public/instance/cls-decl.template +/*--- +description: Decorator can't return an invalid value (public field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec(value) { + return 123; +} + + +function evaluate() { + class C { + @dec + + element; + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/statements/class/decorator/field/private/instance/context-access-set.js b/test/language/statements/class/decorator/field/private/instance/context-access-set.js new file mode 100644 index 00000000000..59571ecb330 --- /dev/null +++ b/test/language/statements/class/decorator/field/private/instance/context-access-set.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-set.case +// - src/decorator/fields/standard/private/instance/cls-decl.template +/*--- +description: Context access `get` works on all gettable types of values (private field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +class C { + @dec + + #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/field/private/instance/context-kind-field.js b/test/language/statements/class/decorator/field/private/instance/context-kind-field.js new file mode 100644 index 00000000000..2ecc0d20f52 --- /dev/null +++ b/test/language/statements/class/decorator/field/private/instance/context-kind-field.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-field.case +// - src/decorator/fields/standard/private/instance/cls-decl.template +/*--- +description: Context kind is the string "field" when decorating a field (private field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "field"); +} + + +class C { + @dec + #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/statements/class/decorator/field/private/instance/context-name-private.js b/test/language/statements/class/decorator/field/private/instance/context-name-private.js new file mode 100644 index 00000000000..f01eb92dfc5 --- /dev/null +++ b/test/language/statements/class/decorator/field/private/instance/context-name-private.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-private.case +// - src/decorator/fields/standard/private/instance/cls-decl.template +/*--- +description: Context name is correct for all types of private elements (private field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "#element"); +} + + +class C { + @dec + #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/statements/class/decorator/field/private/instance/context-private-false.js b/test/language/statements/class/decorator/field/private/instance/context-private-false.js new file mode 100644 index 00000000000..075b8471b6f --- /dev/null +++ b/test/language/statements/class/decorator/field/private/instance/context-private-false.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-private-false.case +// - src/decorator/fields/standard/private/instance/cls-decl.template +/*--- +description: Context `private` is true for all types of private elements (private field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.private, true); +} + + +class C { + @dec + #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/statements/class/decorator/field/private/instance/context-static-false.js b/test/language/statements/class/decorator/field/private/instance/context-static-false.js new file mode 100644 index 00000000000..8a4767b082b --- /dev/null +++ b/test/language/statements/class/decorator/field/private/instance/context-static-false.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-static-false.case +// - src/decorator/fields/standard/private/instance/cls-decl.template +/*--- +description: Context `static` is false for all types of instance elements (private field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.static, false); +} + + +class C { + @dec + #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/statements/class/decorator/field/private/instance/field-and-accessor-init-this.js b/test/language/statements/class/decorator/field/private/instance/field-and-accessor-init-this.js new file mode 100644 index 00000000000..470aabdff5c --- /dev/null +++ b/test/language/statements/class/decorator/field/private/instance/field-and-accessor-init-this.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/fields/standard/private/instance/cls-decl.template +/*--- +description: Field initializer `this` value is the instance or the class (private field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +class C { + @dec + + #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/statements/class/decorator/field/private/instance/field-deco-returns-initializer.js b/test/language/statements/class/decorator/field/private/instance/field-deco-returns-initializer.js new file mode 100644 index 00000000000..05e4474cdaa --- /dev/null +++ b/test/language/statements/class/decorator/field/private/instance/field-deco-returns-initializer.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-deco-returns-initializer.case +// - src/decorator/fields/standard/private/instance/cls-decl.template +/*--- +description: Decorator and initializer order (private field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec(value) { + return (init) => { + assert.sameValue(init, undefined); + return 123; + } +} + + +class C { + @dec + + #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 123); diff --git a/test/language/statements/class/decorator/field/private/instance/field-deco-returns-undefined.js b/test/language/statements/class/decorator/field/private/instance/field-deco-returns-undefined.js new file mode 100644 index 00000000000..cdf71afd199 --- /dev/null +++ b/test/language/statements/class/decorator/field/private/instance/field-deco-returns-undefined.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-deco-returns-undefined.case +// - src/decorator/fields/standard/private/instance/cls-decl.template +/*--- +description: Decorator can return undefined (private field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec(value) { + assert.sameValue(value, undefined); +} + + +class C { + @dec + + #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), undefined); diff --git a/test/language/statements/class/decorator/field/private/static/context-access-set.js b/test/language/statements/class/decorator/field/private/static/context-access-set.js new file mode 100644 index 00000000000..1b74b81df41 --- /dev/null +++ b/test/language/statements/class/decorator/field/private/static/context-access-set.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-set.case +// - src/decorator/fields/standard/private/static/cls-decl.template +/*--- +description: Context access `get` works on all gettable types of values (private static field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +class C { + @dec + + static #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/field/private/static/context-kind-field.js b/test/language/statements/class/decorator/field/private/static/context-kind-field.js new file mode 100644 index 00000000000..bdd652a7e6b --- /dev/null +++ b/test/language/statements/class/decorator/field/private/static/context-kind-field.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-field.case +// - src/decorator/fields/standard/private/static/cls-decl.template +/*--- +description: Context kind is the string "field" when decorating a field (private static field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "field"); +} + + +class C { + @dec + static #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/field/private/static/context-name-private.js b/test/language/statements/class/decorator/field/private/static/context-name-private.js new file mode 100644 index 00000000000..adf5aa9fa24 --- /dev/null +++ b/test/language/statements/class/decorator/field/private/static/context-name-private.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-private.case +// - src/decorator/fields/standard/private/static/cls-decl.template +/*--- +description: Context name is correct for all types of private elements (private static field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "#element"); +} + + +class C { + @dec + static #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/field/private/static/context-private-false.js b/test/language/statements/class/decorator/field/private/static/context-private-false.js new file mode 100644 index 00000000000..7e2504d4e0b --- /dev/null +++ b/test/language/statements/class/decorator/field/private/static/context-private-false.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-private-false.case +// - src/decorator/fields/standard/private/static/cls-decl.template +/*--- +description: Context `private` is true for all types of private elements (private static field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.private, true); +} + + +class C { + @dec + static #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/field/private/static/context-static-true.js b/test/language/statements/class/decorator/field/private/static/context-static-true.js new file mode 100644 index 00000000000..e53f3be03d4 --- /dev/null +++ b/test/language/statements/class/decorator/field/private/static/context-static-true.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-static-true.case +// - src/decorator/fields/standard/private/static/cls-decl.template +/*--- +description: Context `static` is false for all types of instance elements (private static field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.static, true); +} + + +class C { + @dec + static #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/field/private/static/field-and-accessor-init-this.js b/test/language/statements/class/decorator/field/private/static/field-and-accessor-init-this.js new file mode 100644 index 00000000000..10dd5496872 --- /dev/null +++ b/test/language/statements/class/decorator/field/private/static/field-and-accessor-init-this.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/fields/standard/private/static/cls-decl.template +/*--- +description: Field initializer `this` value is the instance or the class (private static field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +class C { + @dec + + static #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/statements/class/decorator/field/private/static/field-deco-returns-initializer.js b/test/language/statements/class/decorator/field/private/static/field-deco-returns-initializer.js new file mode 100644 index 00000000000..274be572694 --- /dev/null +++ b/test/language/statements/class/decorator/field/private/static/field-deco-returns-initializer.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-deco-returns-initializer.case +// - src/decorator/fields/standard/private/static/cls-decl.template +/*--- +description: Decorator and initializer order (private static field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec(value) { + return (init) => { + assert.sameValue(init, undefined); + return 123; + } +} + + +class C { + @dec + + static #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 123); diff --git a/test/language/statements/class/decorator/field/private/static/field-deco-returns-undefined.js b/test/language/statements/class/decorator/field/private/static/field-deco-returns-undefined.js new file mode 100644 index 00000000000..c2708589ad3 --- /dev/null +++ b/test/language/statements/class/decorator/field/private/static/field-deco-returns-undefined.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-deco-returns-undefined.case +// - src/decorator/fields/standard/private/static/cls-decl.template +/*--- +description: Decorator can return undefined (private static field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec(value) { + assert.sameValue(value, undefined); +} + + +class C { + @dec + + static #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), undefined); diff --git a/test/language/statements/class/decorator/field/public/instance/context-access-set.js b/test/language/statements/class/decorator/field/public/instance/context-access-set.js new file mode 100644 index 00000000000..4685ceefde2 --- /dev/null +++ b/test/language/statements/class/decorator/field/public/instance/context-access-set.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-set.case +// - src/decorator/fields/standard/public/instance/cls-decl.template +/*--- +description: Context access `get` works on all gettable types of values (public field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +class C { + @dec + + element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/field/public/instance/context-kind-field.js b/test/language/statements/class/decorator/field/public/instance/context-kind-field.js new file mode 100644 index 00000000000..ee2cdbcb508 --- /dev/null +++ b/test/language/statements/class/decorator/field/public/instance/context-kind-field.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-field.case +// - src/decorator/fields/standard/public/instance/cls-decl.template +/*--- +description: Context kind is the string "field" when decorating a field (public field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "field"); +} + + +class C { + @dec + element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/statements/class/decorator/field/public/instance/context-name-public.js b/test/language/statements/class/decorator/field/public/instance/context-name-public.js new file mode 100644 index 00000000000..37e5855bf93 --- /dev/null +++ b/test/language/statements/class/decorator/field/public/instance/context-name-public.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-public.case +// - src/decorator/fields/standard/public/instance/cls-decl.template +/*--- +description: Context name is correct for all types of public elements (public field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "element"); +} + + +class C { + @dec + element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/statements/class/decorator/field/public/instance/context-private-true.js b/test/language/statements/class/decorator/field/public/instance/context-private-true.js new file mode 100644 index 00000000000..ee3f8dbc5c1 --- /dev/null +++ b/test/language/statements/class/decorator/field/public/instance/context-private-true.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-private-true.case +// - src/decorator/fields/standard/public/instance/cls-decl.template +/*--- +description: Context `private` is false for all types of public elements (public field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.private, false); +} + + +class C { + @dec + element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/statements/class/decorator/field/public/instance/context-static-false.js b/test/language/statements/class/decorator/field/public/instance/context-static-false.js new file mode 100644 index 00000000000..a5c843f3fa7 --- /dev/null +++ b/test/language/statements/class/decorator/field/public/instance/context-static-false.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-static-false.case +// - src/decorator/fields/standard/public/instance/cls-decl.template +/*--- +description: Context `static` is false for all types of instance elements (public field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.static, false); +} + + +class C { + @dec + element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/statements/class/decorator/field/public/instance/field-and-accessor-init-this.js b/test/language/statements/class/decorator/field/public/instance/field-and-accessor-init-this.js new file mode 100644 index 00000000000..c0ada983ce4 --- /dev/null +++ b/test/language/statements/class/decorator/field/public/instance/field-and-accessor-init-this.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/fields/standard/public/instance/cls-decl.template +/*--- +description: Field initializer `this` value is the instance or the class (public field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +class C { + @dec + + element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/statements/class/decorator/field/public/instance/field-deco-returns-initializer.js b/test/language/statements/class/decorator/field/public/instance/field-deco-returns-initializer.js new file mode 100644 index 00000000000..edb8d475c1c --- /dev/null +++ b/test/language/statements/class/decorator/field/public/instance/field-deco-returns-initializer.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-deco-returns-initializer.case +// - src/decorator/fields/standard/public/instance/cls-decl.template +/*--- +description: Decorator and initializer order (public field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec(value) { + return (init) => { + assert.sameValue(init, undefined); + return 123; + } +} + + +class C { + @dec + + element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 123); diff --git a/test/language/statements/class/decorator/field/public/instance/field-deco-returns-undefined.js b/test/language/statements/class/decorator/field/public/instance/field-deco-returns-undefined.js new file mode 100644 index 00000000000..c404f2757cd --- /dev/null +++ b/test/language/statements/class/decorator/field/public/instance/field-deco-returns-undefined.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-deco-returns-undefined.case +// - src/decorator/fields/standard/public/instance/cls-decl.template +/*--- +description: Decorator can return undefined (public field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec(value) { + assert.sameValue(value, undefined); +} + + +class C { + @dec + + element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), undefined); diff --git a/test/language/statements/class/decorator/field/public/static/context-access-set.js b/test/language/statements/class/decorator/field/public/static/context-access-set.js new file mode 100644 index 00000000000..53a9acb1c82 --- /dev/null +++ b/test/language/statements/class/decorator/field/public/static/context-access-set.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-set.case +// - src/decorator/fields/standard/public/static/cls-decl.template +/*--- +description: Context access `get` works on all gettable types of values (public static field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +class C { + @dec + + static element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/field/public/static/context-kind-field.js b/test/language/statements/class/decorator/field/public/static/context-kind-field.js new file mode 100644 index 00000000000..c2965698015 --- /dev/null +++ b/test/language/statements/class/decorator/field/public/static/context-kind-field.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-field.case +// - src/decorator/fields/standard/public/static/cls-decl.template +/*--- +description: Context kind is the string "field" when decorating a field (public static field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "field"); +} + + +class C { + @dec + static element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/field/public/static/context-name-public.js b/test/language/statements/class/decorator/field/public/static/context-name-public.js new file mode 100644 index 00000000000..730dde67b01 --- /dev/null +++ b/test/language/statements/class/decorator/field/public/static/context-name-public.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-public.case +// - src/decorator/fields/standard/public/static/cls-decl.template +/*--- +description: Context name is correct for all types of public elements (public static field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "element"); +} + + +class C { + @dec + static element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/field/public/static/context-private-true.js b/test/language/statements/class/decorator/field/public/static/context-private-true.js new file mode 100644 index 00000000000..5b4484bbe3a --- /dev/null +++ b/test/language/statements/class/decorator/field/public/static/context-private-true.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-private-true.case +// - src/decorator/fields/standard/public/static/cls-decl.template +/*--- +description: Context `private` is false for all types of public elements (public static field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.private, false); +} + + +class C { + @dec + static element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/field/public/static/context-static-true.js b/test/language/statements/class/decorator/field/public/static/context-static-true.js new file mode 100644 index 00000000000..1db648a8ccf --- /dev/null +++ b/test/language/statements/class/decorator/field/public/static/context-static-true.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-static-true.case +// - src/decorator/fields/standard/public/static/cls-decl.template +/*--- +description: Context `static` is false for all types of instance elements (public static field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.static, true); +} + + +class C { + @dec + static element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/field/public/static/field-and-accessor-init-this.js b/test/language/statements/class/decorator/field/public/static/field-and-accessor-init-this.js new file mode 100644 index 00000000000..5bd1dacc69b --- /dev/null +++ b/test/language/statements/class/decorator/field/public/static/field-and-accessor-init-this.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/fields/standard/public/static/cls-decl.template +/*--- +description: Field initializer `this` value is the instance or the class (public static field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +class C { + @dec + + static element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/statements/class/decorator/field/public/static/field-deco-invalid-return.js b/test/language/statements/class/decorator/field/public/static/field-deco-invalid-return.js new file mode 100644 index 00000000000..be565d138e5 --- /dev/null +++ b/test/language/statements/class/decorator/field/public/static/field-deco-invalid-return.js @@ -0,0 +1,26 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-deco-invalid-return.case +// - src/decorator/fields/error/public/static/cls-decl.template +/*--- +description: Decorator can't return an invalid value (public static field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec(value) { + return 123; +} + + +function evaluate() { + class C { + @dec + + static element; + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/statements/class/decorator/field/public/static/field-deco-returns-initializer.js b/test/language/statements/class/decorator/field/public/static/field-deco-returns-initializer.js new file mode 100644 index 00000000000..d6904c9b32f --- /dev/null +++ b/test/language/statements/class/decorator/field/public/static/field-deco-returns-initializer.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-deco-returns-initializer.case +// - src/decorator/fields/standard/public/static/cls-decl.template +/*--- +description: Decorator and initializer order (public static field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec(value) { + return (init) => { + assert.sameValue(init, undefined); + return 123; + } +} + + +class C { + @dec + + static element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 123); diff --git a/test/language/statements/class/decorator/field/public/static/field-deco-returns-undefined.js b/test/language/statements/class/decorator/field/public/static/field-deco-returns-undefined.js new file mode 100644 index 00000000000..3b8efd40837 --- /dev/null +++ b/test/language/statements/class/decorator/field/public/static/field-deco-returns-undefined.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-deco-returns-undefined.case +// - src/decorator/fields/standard/public/static/cls-decl.template +/*--- +description: Decorator can return undefined (public static field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec(value) { + assert.sameValue(value, undefined); +} + + +class C { + @dec + + static element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), undefined); diff --git a/test/language/statements/class/decorator/field/with-init/private/instance/context-access-get.js b/test/language/statements/class/decorator/field/with-init/private/instance/context-access-get.js new file mode 100644 index 00000000000..bc3e4ff0d8f --- /dev/null +++ b/test/language/statements/class/decorator/field/with-init/private/instance/context-access-get.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-get.case +// - src/decorator/fields/with-init/private/instance/cls-decl.template +/*--- +description: Context access `get` works on all gettable types of values (private field with initializer decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +class C { + @dec + + #element = 123 +; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), access.get(classOrInstance)); diff --git a/test/language/statements/class/decorator/field/with-init/private/instance/context-access-set.js b/test/language/statements/class/decorator/field/with-init/private/instance/context-access-set.js new file mode 100644 index 00000000000..602020f07a8 --- /dev/null +++ b/test/language/statements/class/decorator/field/with-init/private/instance/context-access-set.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-set.case +// - src/decorator/fields/with-init/private/instance/cls-decl.template +/*--- +description: Context access `get` works on all gettable types of values (private field with initializer decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +class C { + @dec + + #element = 123 +; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/field/with-init/private/instance/decorator-order-application-field-and-accessor.js b/test/language/statements/class/decorator/field/with-init/private/instance/decorator-order-application-field-and-accessor.js new file mode 100644 index 00000000000..f2576ba2930 --- /dev/null +++ b/test/language/statements/class/decorator/field/with-init/private/instance/decorator-order-application-field-and-accessor.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-order-application-field-and-accessor.case +// - src/decorator/fields/with-init/private/instance/cls-decl.template +/*--- +description: Order of decorator application for elements with initializers (private field with initializer decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +var ord = []; + +function pushOrd(applyOrd, initOrd, extraInitOrd) { + return (value, context) => { + ord.push(applyOrd); + context.addInitializer(() => ord.push(extraInitOrd)); + + if (context.kind === 'field') { + return () => ord.push(initOrd); + } else { + return { + init() { + ord.push(initOrd); + } + } + } + } +} + + +class C { + @pushOrd(1, 3, 6) + @pushOrd(0, 4, 5) + + #element = ord.push(2) +; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(ord.length, 7); +ord.forEach(assert.sameValue); diff --git a/test/language/statements/class/decorator/field/with-init/private/instance/field-and-accessor-init-this.js b/test/language/statements/class/decorator/field/with-init/private/instance/field-and-accessor-init-this.js new file mode 100644 index 00000000000..f372dde69e8 --- /dev/null +++ b/test/language/statements/class/decorator/field/with-init/private/instance/field-and-accessor-init-this.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/fields/with-init/private/instance/cls-decl.template +/*--- +description: Field initializer `this` value is the instance or the class (private field with initializer decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +class C { + @dec + + #element = savedThisValues.push(this); +; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/statements/class/decorator/field/with-init/private/instance/field-receives-undefined.js b/test/language/statements/class/decorator/field/with-init/private/instance/field-receives-undefined.js new file mode 100644 index 00000000000..ea6bc4d51f6 --- /dev/null +++ b/test/language/statements/class/decorator/field/with-init/private/instance/field-receives-undefined.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-receives-undefined.case +// - src/decorator/fields/with-init/private/instance/cls-decl.template +/*--- +description: Value passed to field decorators is undefined (private field with initializer decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +function dec(value) { + assert.sameValue(value, undefined); +} + + +class C { + @dec + #element = 123 +; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/statements/class/decorator/field/with-init/private/instance/field-with-init-deco-returns-initializer.js b/test/language/statements/class/decorator/field/with-init/private/instance/field-with-init-deco-returns-initializer.js new file mode 100644 index 00000000000..7c3b91cd940 --- /dev/null +++ b/test/language/statements/class/decorator/field/with-init/private/instance/field-with-init-deco-returns-initializer.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-with-init-deco-returns-initializer.case +// - src/decorator/fields/with-init/private/instance/cls-decl.template +/*--- +description: Decorator initializer is called with initial value during initialization (private field with initializer decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +info: | + InitializeFieldOrAccessor ( receiver, elementRecord ) + + ... + +---*/ + + +function dec(value) { + return (init) => { + assert.sameValue(init, 123); + return 456; + } +} + + +class C { + @dec + + #element = 123 +; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/field/with-init/private/instance/field-with-init-deco-returns-undefined.js b/test/language/statements/class/decorator/field/with-init/private/instance/field-with-init-deco-returns-undefined.js new file mode 100644 index 00000000000..dfe724e049c --- /dev/null +++ b/test/language/statements/class/decorator/field/with-init/private/instance/field-with-init-deco-returns-undefined.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-with-init-deco-returns-undefined.case +// - src/decorator/fields/with-init/private/instance/cls-decl.template +/*--- +description: Decorator initializer is called with initial value during initialization (private field with initializer decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +info: | + InitializeFieldOrAccessor ( receiver, elementRecord ) + + ... + +---*/ + + +function dec(value) { + assert.sameValue(value, undefined); +} + + +class C { + @dec + + #element = 123 +; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 123); diff --git a/test/language/statements/class/decorator/field/with-init/private/static/context-access-get.js b/test/language/statements/class/decorator/field/with-init/private/static/context-access-get.js new file mode 100644 index 00000000000..ea7cb0f7d6b --- /dev/null +++ b/test/language/statements/class/decorator/field/with-init/private/static/context-access-get.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-get.case +// - src/decorator/fields/with-init/private/static/cls-decl.template +/*--- +description: Context access `get` works on all gettable types of values (private static with initializer field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +class C { + @dec + + static #element = 123 +; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), access.get(classOrInstance)); diff --git a/test/language/statements/class/decorator/field/with-init/private/static/context-access-set.js b/test/language/statements/class/decorator/field/with-init/private/static/context-access-set.js new file mode 100644 index 00000000000..b3456bc3da0 --- /dev/null +++ b/test/language/statements/class/decorator/field/with-init/private/static/context-access-set.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-set.case +// - src/decorator/fields/with-init/private/static/cls-decl.template +/*--- +description: Context access `get` works on all gettable types of values (private static with initializer field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +class C { + @dec + + static #element = 123 +; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/field/with-init/private/static/decorator-order-application-field-and-accessor.js b/test/language/statements/class/decorator/field/with-init/private/static/decorator-order-application-field-and-accessor.js new file mode 100644 index 00000000000..11d81726c94 --- /dev/null +++ b/test/language/statements/class/decorator/field/with-init/private/static/decorator-order-application-field-and-accessor.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-order-application-field-and-accessor.case +// - src/decorator/fields/with-init/private/static/cls-decl.template +/*--- +description: Order of decorator application for elements with initializers (private static with initializer field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +var ord = []; + +function pushOrd(applyOrd, initOrd, extraInitOrd) { + return (value, context) => { + ord.push(applyOrd); + context.addInitializer(() => ord.push(extraInitOrd)); + + if (context.kind === 'field') { + return () => ord.push(initOrd); + } else { + return { + init() { + ord.push(initOrd); + } + } + } + } +} + + +class C { + @pushOrd(1, 3, 6) + @pushOrd(0, 4, 5) + + static #element = ord.push(2) +; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(ord.length, 7); +ord.forEach(assert.sameValue); diff --git a/test/language/statements/class/decorator/field/with-init/private/static/field-and-accessor-init-this.js b/test/language/statements/class/decorator/field/with-init/private/static/field-and-accessor-init-this.js new file mode 100644 index 00000000000..a2fb251938b --- /dev/null +++ b/test/language/statements/class/decorator/field/with-init/private/static/field-and-accessor-init-this.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/fields/with-init/private/static/cls-decl.template +/*--- +description: Field initializer `this` value is the instance or the class (private static with initializer field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +class C { + @dec + + static #element = savedThisValues.push(this); +; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/statements/class/decorator/field/with-init/private/static/field-receives-undefined.js b/test/language/statements/class/decorator/field/with-init/private/static/field-receives-undefined.js new file mode 100644 index 00000000000..6dd9af21df2 --- /dev/null +++ b/test/language/statements/class/decorator/field/with-init/private/static/field-receives-undefined.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-receives-undefined.case +// - src/decorator/fields/with-init/private/static/cls-decl.template +/*--- +description: Value passed to field decorators is undefined (private static with initializer field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +function dec(value) { + assert.sameValue(value, undefined); +} + + +class C { + @dec + static #element = 123 +; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/field/with-init/private/static/field-with-init-deco-returns-initializer.js b/test/language/statements/class/decorator/field/with-init/private/static/field-with-init-deco-returns-initializer.js new file mode 100644 index 00000000000..dd4c3cb698d --- /dev/null +++ b/test/language/statements/class/decorator/field/with-init/private/static/field-with-init-deco-returns-initializer.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-with-init-deco-returns-initializer.case +// - src/decorator/fields/with-init/private/static/cls-decl.template +/*--- +description: Decorator initializer is called with initial value during initialization (private static with initializer field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +info: | + InitializeFieldOrAccessor ( receiver, elementRecord ) + + ... + +---*/ + + +function dec(value) { + return (init) => { + assert.sameValue(init, 123); + return 456; + } +} + + +class C { + @dec + + static #element = 123 +; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/field/with-init/private/static/field-with-init-deco-returns-undefined.js b/test/language/statements/class/decorator/field/with-init/private/static/field-with-init-deco-returns-undefined.js new file mode 100644 index 00000000000..791d18cb186 --- /dev/null +++ b/test/language/statements/class/decorator/field/with-init/private/static/field-with-init-deco-returns-undefined.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-with-init-deco-returns-undefined.case +// - src/decorator/fields/with-init/private/static/cls-decl.template +/*--- +description: Decorator initializer is called with initial value during initialization (private static with initializer field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +info: | + InitializeFieldOrAccessor ( receiver, elementRecord ) + + ... + +---*/ + + +function dec(value) { + assert.sameValue(value, undefined); +} + + +class C { + @dec + + static #element = 123 +; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 123); diff --git a/test/language/statements/class/decorator/field/with-init/public/instance/context-access-get.js b/test/language/statements/class/decorator/field/with-init/public/instance/context-access-get.js new file mode 100644 index 00000000000..1a31be38349 --- /dev/null +++ b/test/language/statements/class/decorator/field/with-init/public/instance/context-access-get.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-get.case +// - src/decorator/fields/with-init/public/instance/cls-decl.template +/*--- +description: Context access `get` works on all gettable types of values (public field with initializer decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +class C { + @dec + + element = 123 +; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), access.get(classOrInstance)); diff --git a/test/language/statements/class/decorator/field/with-init/public/instance/context-access-set.js b/test/language/statements/class/decorator/field/with-init/public/instance/context-access-set.js new file mode 100644 index 00000000000..1db5a601141 --- /dev/null +++ b/test/language/statements/class/decorator/field/with-init/public/instance/context-access-set.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-set.case +// - src/decorator/fields/with-init/public/instance/cls-decl.template +/*--- +description: Context access `get` works on all gettable types of values (public field with initializer decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +class C { + @dec + + element = 123 +; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/field/with-init/public/instance/decorator-order-application-field-and-accessor.js b/test/language/statements/class/decorator/field/with-init/public/instance/decorator-order-application-field-and-accessor.js new file mode 100644 index 00000000000..38fdba56597 --- /dev/null +++ b/test/language/statements/class/decorator/field/with-init/public/instance/decorator-order-application-field-and-accessor.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-order-application-field-and-accessor.case +// - src/decorator/fields/with-init/public/instance/cls-decl.template +/*--- +description: Order of decorator application for elements with initializers (public field with initializer decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +var ord = []; + +function pushOrd(applyOrd, initOrd, extraInitOrd) { + return (value, context) => { + ord.push(applyOrd); + context.addInitializer(() => ord.push(extraInitOrd)); + + if (context.kind === 'field') { + return () => ord.push(initOrd); + } else { + return { + init() { + ord.push(initOrd); + } + } + } + } +} + + +class C { + @pushOrd(1, 3, 6) + @pushOrd(0, 4, 5) + + element = ord.push(2) +; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(ord.length, 7); +ord.forEach(assert.sameValue); diff --git a/test/language/statements/class/decorator/field/with-init/public/instance/field-and-accessor-init-this.js b/test/language/statements/class/decorator/field/with-init/public/instance/field-and-accessor-init-this.js new file mode 100644 index 00000000000..ffa50c9cf0c --- /dev/null +++ b/test/language/statements/class/decorator/field/with-init/public/instance/field-and-accessor-init-this.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/fields/with-init/public/instance/cls-decl.template +/*--- +description: Field initializer `this` value is the instance or the class (public field with initializer decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +class C { + @dec + + element = savedThisValues.push(this); +; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/statements/class/decorator/field/with-init/public/instance/field-receives-undefined.js b/test/language/statements/class/decorator/field/with-init/public/instance/field-receives-undefined.js new file mode 100644 index 00000000000..0e529f79b2d --- /dev/null +++ b/test/language/statements/class/decorator/field/with-init/public/instance/field-receives-undefined.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-receives-undefined.case +// - src/decorator/fields/with-init/public/instance/cls-decl.template +/*--- +description: Value passed to field decorators is undefined (public field with initializer decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +function dec(value) { + assert.sameValue(value, undefined); +} + + +class C { + @dec + element = 123 +; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/statements/class/decorator/field/with-init/public/instance/field-with-init-deco-returns-initializer.js b/test/language/statements/class/decorator/field/with-init/public/instance/field-with-init-deco-returns-initializer.js new file mode 100644 index 00000000000..9cd0097cfe9 --- /dev/null +++ b/test/language/statements/class/decorator/field/with-init/public/instance/field-with-init-deco-returns-initializer.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-with-init-deco-returns-initializer.case +// - src/decorator/fields/with-init/public/instance/cls-decl.template +/*--- +description: Decorator initializer is called with initial value during initialization (public field with initializer decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +info: | + InitializeFieldOrAccessor ( receiver, elementRecord ) + + ... + +---*/ + + +function dec(value) { + return (init) => { + assert.sameValue(init, 123); + return 456; + } +} + + +class C { + @dec + + element = 123 +; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/field/with-init/public/instance/field-with-init-deco-returns-undefined.js b/test/language/statements/class/decorator/field/with-init/public/instance/field-with-init-deco-returns-undefined.js new file mode 100644 index 00000000000..948f6798b45 --- /dev/null +++ b/test/language/statements/class/decorator/field/with-init/public/instance/field-with-init-deco-returns-undefined.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-with-init-deco-returns-undefined.case +// - src/decorator/fields/with-init/public/instance/cls-decl.template +/*--- +description: Decorator initializer is called with initial value during initialization (public field with initializer decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +info: | + InitializeFieldOrAccessor ( receiver, elementRecord ) + + ... + +---*/ + + +function dec(value) { + assert.sameValue(value, undefined); +} + + +class C { + @dec + + element = 123 +; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 123); diff --git a/test/language/statements/class/decorator/field/with-init/public/static/context-access-get.js b/test/language/statements/class/decorator/field/with-init/public/static/context-access-get.js new file mode 100644 index 00000000000..7002cb77bd3 --- /dev/null +++ b/test/language/statements/class/decorator/field/with-init/public/static/context-access-get.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-get.case +// - src/decorator/fields/with-init/public/static/cls-decl.template +/*--- +description: Context access `get` works on all gettable types of values (public static with initializer field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +class C { + @dec + + static element = 123 +; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), access.get(classOrInstance)); diff --git a/test/language/statements/class/decorator/field/with-init/public/static/context-access-set.js b/test/language/statements/class/decorator/field/with-init/public/static/context-access-set.js new file mode 100644 index 00000000000..89b27ea2e41 --- /dev/null +++ b/test/language/statements/class/decorator/field/with-init/public/static/context-access-set.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-set.case +// - src/decorator/fields/with-init/public/static/cls-decl.template +/*--- +description: Context access `get` works on all gettable types of values (public static with initializer field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +class C { + @dec + + static element = 123 +; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/field/with-init/public/static/decorator-order-application-field-and-accessor.js b/test/language/statements/class/decorator/field/with-init/public/static/decorator-order-application-field-and-accessor.js new file mode 100644 index 00000000000..d77a13d2548 --- /dev/null +++ b/test/language/statements/class/decorator/field/with-init/public/static/decorator-order-application-field-and-accessor.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-order-application-field-and-accessor.case +// - src/decorator/fields/with-init/public/static/cls-decl.template +/*--- +description: Order of decorator application for elements with initializers (public static with initializer field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +var ord = []; + +function pushOrd(applyOrd, initOrd, extraInitOrd) { + return (value, context) => { + ord.push(applyOrd); + context.addInitializer(() => ord.push(extraInitOrd)); + + if (context.kind === 'field') { + return () => ord.push(initOrd); + } else { + return { + init() { + ord.push(initOrd); + } + } + } + } +} + + +class C { + @pushOrd(1, 3, 6) + @pushOrd(0, 4, 5) + + static element = ord.push(2) +; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(ord.length, 7); +ord.forEach(assert.sameValue); diff --git a/test/language/statements/class/decorator/field/with-init/public/static/field-and-accessor-init-this.js b/test/language/statements/class/decorator/field/with-init/public/static/field-and-accessor-init-this.js new file mode 100644 index 00000000000..913a624ced3 --- /dev/null +++ b/test/language/statements/class/decorator/field/with-init/public/static/field-and-accessor-init-this.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/fields/with-init/public/static/cls-decl.template +/*--- +description: Field initializer `this` value is the instance or the class (public static with initializer field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +class C { + @dec + + static element = savedThisValues.push(this); +; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/statements/class/decorator/field/with-init/public/static/field-receives-undefined.js b/test/language/statements/class/decorator/field/with-init/public/static/field-receives-undefined.js new file mode 100644 index 00000000000..39cf47f12dd --- /dev/null +++ b/test/language/statements/class/decorator/field/with-init/public/static/field-receives-undefined.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-receives-undefined.case +// - src/decorator/fields/with-init/public/static/cls-decl.template +/*--- +description: Value passed to field decorators is undefined (public static with initializer field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +function dec(value) { + assert.sameValue(value, undefined); +} + + +class C { + @dec + static element = 123 +; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/field/with-init/public/static/field-with-init-deco-returns-initializer.js b/test/language/statements/class/decorator/field/with-init/public/static/field-with-init-deco-returns-initializer.js new file mode 100644 index 00000000000..babf9863e4b --- /dev/null +++ b/test/language/statements/class/decorator/field/with-init/public/static/field-with-init-deco-returns-initializer.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-with-init-deco-returns-initializer.case +// - src/decorator/fields/with-init/public/static/cls-decl.template +/*--- +description: Decorator initializer is called with initial value during initialization (public static with initializer field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +info: | + InitializeFieldOrAccessor ( receiver, elementRecord ) + + ... + +---*/ + + +function dec(value) { + return (init) => { + assert.sameValue(init, 123); + return 456; + } +} + + +class C { + @dec + + static element = 123 +; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/field/with-init/public/static/field-with-init-deco-returns-undefined.js b/test/language/statements/class/decorator/field/with-init/public/static/field-with-init-deco-returns-undefined.js new file mode 100644 index 00000000000..d4a7a98c5d6 --- /dev/null +++ b/test/language/statements/class/decorator/field/with-init/public/static/field-with-init-deco-returns-undefined.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-with-init-deco-returns-undefined.case +// - src/decorator/fields/with-init/public/static/cls-decl.template +/*--- +description: Decorator initializer is called with initial value during initialization (public static with initializer field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +info: | + InitializeFieldOrAccessor ( receiver, elementRecord ) + + ... + +---*/ + + +function dec(value) { + assert.sameValue(value, undefined); +} + + +class C { + @dec + + static element = 123 +; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 123); diff --git a/test/language/statements/class/decorator/getter/error/private/instance/getter-deco-returns-invalid.js b/test/language/statements/class/decorator/getter/error/private/instance/getter-deco-returns-invalid.js new file mode 100644 index 00000000000..bd527f4f62f --- /dev/null +++ b/test/language/statements/class/decorator/getter/error/private/instance/getter-deco-returns-invalid.js @@ -0,0 +1,25 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/getter-deco-returns-invalid.case +// - src/decorator/getters/error/private/instance/cls-decl.template +/*--- +description: Decorator can't return an invalid value (private getter decorator evaluation error in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + return 123; +} + + +function evaluate() { + class C { + @dec + + get #element() {} + } +} + +assert.throws(TypeError, evaluate); diff --git a/test/language/statements/class/decorator/getter/error/private/static/context-kind-getter.js b/test/language/statements/class/decorator/getter/error/private/static/context-kind-getter.js new file mode 100644 index 00000000000..3a75584bf75 --- /dev/null +++ b/test/language/statements/class/decorator/getter/error/private/static/context-kind-getter.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-getter.case +// - src/decorator/getters/standard/private/static/cls-decl.template +/*--- +description: Context kind is the string "method" when decorating a method (private static getter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "getter"); +} + + +class C { + static internalValue = 123; + + @dec + static get #element() { + return this.internalValue; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/getter/error/private/static/context-name-private.js b/test/language/statements/class/decorator/getter/error/private/static/context-name-private.js new file mode 100644 index 00000000000..0a95b922e87 --- /dev/null +++ b/test/language/statements/class/decorator/getter/error/private/static/context-name-private.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-private.case +// - src/decorator/getters/standard/private/static/cls-decl.template +/*--- +description: Context name is correct for all types of private elements (private static getter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "#element"); +} + + +class C { + static internalValue = 123; + + @dec + static get #element() { + return this.internalValue; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/getter/error/private/static/context-private-false.js b/test/language/statements/class/decorator/getter/error/private/static/context-private-false.js new file mode 100644 index 00000000000..d59c8508890 --- /dev/null +++ b/test/language/statements/class/decorator/getter/error/private/static/context-private-false.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-private-false.case +// - src/decorator/getters/standard/private/static/cls-decl.template +/*--- +description: Context `private` is true for all types of private elements (private static getter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.private, true); +} + + +class C { + static internalValue = 123; + + @dec + static get #element() { + return this.internalValue; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/getter/error/private/static/context-static-true.js b/test/language/statements/class/decorator/getter/error/private/static/context-static-true.js new file mode 100644 index 00000000000..16d07fe81c8 --- /dev/null +++ b/test/language/statements/class/decorator/getter/error/private/static/context-static-true.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-static-true.case +// - src/decorator/getters/standard/private/static/cls-decl.template +/*--- +description: Context `static` is false for all types of instance elements (private static getter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.static, true); +} + + +class C { + static internalValue = 123; + + @dec + static get #element() { + return this.internalValue; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/getter/error/private/static/getter-deco-returns-invalid.js b/test/language/statements/class/decorator/getter/error/private/static/getter-deco-returns-invalid.js new file mode 100644 index 00000000000..1fd14dc4659 --- /dev/null +++ b/test/language/statements/class/decorator/getter/error/private/static/getter-deco-returns-invalid.js @@ -0,0 +1,26 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/getter-deco-returns-invalid.case +// - src/decorator/getters/error/private/static/cls-decl.template +/*--- +description: Decorator can't return an invalid value (private static getter decorator evaluation error in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + return 123; +} + + +function evaluate() { + class C { + @dec + + static get #element() {} + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/statements/class/decorator/getter/error/private/static/getter-deco-returns-replacement.js b/test/language/statements/class/decorator/getter/error/private/static/getter-deco-returns-replacement.js new file mode 100644 index 00000000000..da9f110c999 --- /dev/null +++ b/test/language/statements/class/decorator/getter/error/private/static/getter-deco-returns-replacement.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/getter-deco-returns-replacement.case +// - src/decorator/getters/standard/private/static/cls-decl.template +/*--- +description: Can replace a decorated getter with a new getter (private static getter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(value, context) { + + return function() { + assert.sameValue(value.call(this), 123); + + return 456; + }; +} + + +class C { + static internalValue = 123; + + @dec + + static get #element() { + return this.internalValue; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/getter/error/private/static/getter-deco-returns-undefined.js b/test/language/statements/class/decorator/getter/error/private/static/getter-deco-returns-undefined.js new file mode 100644 index 00000000000..d212b8b806c --- /dev/null +++ b/test/language/statements/class/decorator/getter/error/private/static/getter-deco-returns-undefined.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/getter-deco-returns-undefined.case +// - src/decorator/getters/standard/private/static/cls-decl.template +/*--- +description: Decorator undefined return defaults to previous value (private static getter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec1(value, context) { + return function() { + assert.sameValue(value.call(this), 123); + + return 456; + }; +} + +function dec2() {} + + +class C { + static internalValue = 123; + + @dec2 @dec1 + + static get #element() { + return this.internalValue; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/getter/error/public/instance/getter-deco-returns-invalid.js b/test/language/statements/class/decorator/getter/error/public/instance/getter-deco-returns-invalid.js new file mode 100644 index 00000000000..912848b038e --- /dev/null +++ b/test/language/statements/class/decorator/getter/error/public/instance/getter-deco-returns-invalid.js @@ -0,0 +1,26 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/getter-deco-returns-invalid.case +// - src/decorator/getters/error/public/instance/cls-decl.template +/*--- +description: Decorator can't return an invalid value (public getter decorator evaluation error in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + return 123; +} + + +function evaluate() { + class C { + @dec + + get element() {} + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/statements/class/decorator/getter/error/public/static/getter-deco-returns-invalid.js b/test/language/statements/class/decorator/getter/error/public/static/getter-deco-returns-invalid.js new file mode 100644 index 00000000000..2f2aa7b3135 --- /dev/null +++ b/test/language/statements/class/decorator/getter/error/public/static/getter-deco-returns-invalid.js @@ -0,0 +1,26 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/getter-deco-returns-invalid.case +// - src/decorator/getters/error/public/static/cls-decl.template +/*--- +description: Decorator can't return an invalid value (public static getter decorator evaluation error in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + return 123; +} + + +function evaluate() { + class C { + @dec + + static get element() {} + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/statements/class/decorator/getter/private/instance/context-kind-getter.js b/test/language/statements/class/decorator/getter/private/instance/context-kind-getter.js new file mode 100644 index 00000000000..3a082a0612d --- /dev/null +++ b/test/language/statements/class/decorator/getter/private/instance/context-kind-getter.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-getter.case +// - src/decorator/getters/standard/private/instance/cls-decl.template +/*--- +description: Context kind is the string "method" when decorating a method (private getter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "getter"); +} + + +class C { + internalValue = 123; + + @dec + get #element() { + return this.internalValue; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/statements/class/decorator/getter/private/instance/context-name-private.js b/test/language/statements/class/decorator/getter/private/instance/context-name-private.js new file mode 100644 index 00000000000..2f5f6a3e4ab --- /dev/null +++ b/test/language/statements/class/decorator/getter/private/instance/context-name-private.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-private.case +// - src/decorator/getters/standard/private/instance/cls-decl.template +/*--- +description: Context name is correct for all types of private elements (private getter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "#element"); +} + + +class C { + internalValue = 123; + + @dec + get #element() { + return this.internalValue; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/statements/class/decorator/getter/private/instance/context-private-false.js b/test/language/statements/class/decorator/getter/private/instance/context-private-false.js new file mode 100644 index 00000000000..f78f5274a54 --- /dev/null +++ b/test/language/statements/class/decorator/getter/private/instance/context-private-false.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-private-false.case +// - src/decorator/getters/standard/private/instance/cls-decl.template +/*--- +description: Context `private` is true for all types of private elements (private getter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.private, true); +} + + +class C { + internalValue = 123; + + @dec + get #element() { + return this.internalValue; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/statements/class/decorator/getter/private/instance/context-static-false.js b/test/language/statements/class/decorator/getter/private/instance/context-static-false.js new file mode 100644 index 00000000000..3c1962ac745 --- /dev/null +++ b/test/language/statements/class/decorator/getter/private/instance/context-static-false.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-static-false.case +// - src/decorator/getters/standard/private/instance/cls-decl.template +/*--- +description: Context `static` is false for all types of instance elements (private getter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.static, false); +} + + +class C { + internalValue = 123; + + @dec + get #element() { + return this.internalValue; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/statements/class/decorator/getter/private/instance/getter-deco-returns-replacement.js b/test/language/statements/class/decorator/getter/private/instance/getter-deco-returns-replacement.js new file mode 100644 index 00000000000..6f72eb726ae --- /dev/null +++ b/test/language/statements/class/decorator/getter/private/instance/getter-deco-returns-replacement.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/getter-deco-returns-replacement.case +// - src/decorator/getters/standard/private/instance/cls-decl.template +/*--- +description: Can replace a decorated getter with a new getter (private getter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(value, context) { + + return function() { + assert.sameValue(value.call(this), 123); + + return 456; + }; +} + + +class C { + internalValue = 123; + + @dec + + get #element() { + return this.internalValue; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/getter/private/instance/getter-deco-returns-undefined.js b/test/language/statements/class/decorator/getter/private/instance/getter-deco-returns-undefined.js new file mode 100644 index 00000000000..ce68f060a1e --- /dev/null +++ b/test/language/statements/class/decorator/getter/private/instance/getter-deco-returns-undefined.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/getter-deco-returns-undefined.case +// - src/decorator/getters/standard/private/instance/cls-decl.template +/*--- +description: Decorator undefined return defaults to previous value (private getter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec1(value, context) { + return function() { + assert.sameValue(value.call(this), 123); + + return 456; + }; +} + +function dec2() {} + + +class C { + internalValue = 123; + + @dec2 @dec1 + + get #element() { + return this.internalValue; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/getter/public/instance/context-kind-getter.js b/test/language/statements/class/decorator/getter/public/instance/context-kind-getter.js new file mode 100644 index 00000000000..979b3acb657 --- /dev/null +++ b/test/language/statements/class/decorator/getter/public/instance/context-kind-getter.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-getter.case +// - src/decorator/getters/standard/public/instance/cls-decl.template +/*--- +description: Context kind is the string "method" when decorating a method (public getter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "getter"); +} + + +class C { + internalValue = 123; + + @dec + get element() { + return this.internalValue; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + + + diff --git a/test/language/statements/class/decorator/getter/public/instance/context-name-public.js b/test/language/statements/class/decorator/getter/public/instance/context-name-public.js new file mode 100644 index 00000000000..3ce2aa05059 --- /dev/null +++ b/test/language/statements/class/decorator/getter/public/instance/context-name-public.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-public.case +// - src/decorator/getters/standard/public/instance/cls-decl.template +/*--- +description: Context name is correct for all types of public elements (public getter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "element"); +} + + +class C { + internalValue = 123; + + @dec + get element() { + return this.internalValue; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + + + diff --git a/test/language/statements/class/decorator/getter/public/instance/context-private-true.js b/test/language/statements/class/decorator/getter/public/instance/context-private-true.js new file mode 100644 index 00000000000..5aee9354519 --- /dev/null +++ b/test/language/statements/class/decorator/getter/public/instance/context-private-true.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-private-true.case +// - src/decorator/getters/standard/public/instance/cls-decl.template +/*--- +description: Context `private` is false for all types of public elements (public getter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.private, false); +} + + +class C { + internalValue = 123; + + @dec + get element() { + return this.internalValue; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + + + diff --git a/test/language/statements/class/decorator/getter/public/instance/context-static-false.js b/test/language/statements/class/decorator/getter/public/instance/context-static-false.js new file mode 100644 index 00000000000..fd175741570 --- /dev/null +++ b/test/language/statements/class/decorator/getter/public/instance/context-static-false.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-static-false.case +// - src/decorator/getters/standard/public/instance/cls-decl.template +/*--- +description: Context `static` is false for all types of instance elements (public getter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.static, false); +} + + +class C { + internalValue = 123; + + @dec + get element() { + return this.internalValue; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + + + diff --git a/test/language/statements/class/decorator/getter/public/instance/getter-deco-returns-replacement.js b/test/language/statements/class/decorator/getter/public/instance/getter-deco-returns-replacement.js new file mode 100644 index 00000000000..e12284f13f5 --- /dev/null +++ b/test/language/statements/class/decorator/getter/public/instance/getter-deco-returns-replacement.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/getter-deco-returns-replacement.case +// - src/decorator/getters/standard/public/instance/cls-decl.template +/*--- +description: Can replace a decorated getter with a new getter (public getter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(value, context) { + + return function() { + assert.sameValue(value.call(this), 123); + + return 456; + }; +} + + +class C { + internalValue = 123; + + @dec + + get element() { + return this.internalValue; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 456); + diff --git a/test/language/statements/class/decorator/getter/public/instance/getter-deco-returns-undefined.js b/test/language/statements/class/decorator/getter/public/instance/getter-deco-returns-undefined.js new file mode 100644 index 00000000000..f5e34c9e6ca --- /dev/null +++ b/test/language/statements/class/decorator/getter/public/instance/getter-deco-returns-undefined.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/getter-deco-returns-undefined.case +// - src/decorator/getters/standard/public/instance/cls-decl.template +/*--- +description: Decorator undefined return defaults to previous value (public getter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec1(value, context) { + return function() { + assert.sameValue(value.call(this), 123); + + return 456; + }; +} + +function dec2() {} + + +class C { + internalValue = 123; + + @dec2 @dec1 + + get element() { + return this.internalValue; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 456); + diff --git a/test/language/statements/class/decorator/getter/public/static/context-kind-getter.js b/test/language/statements/class/decorator/getter/public/static/context-kind-getter.js new file mode 100644 index 00000000000..bd2e35a64cf --- /dev/null +++ b/test/language/statements/class/decorator/getter/public/static/context-kind-getter.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-getter.case +// - src/decorator/getters/standard/public/static/cls-decl.template +/*--- +description: Context kind is the string "method" when decorating a method (public static getter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "getter"); +} + + +class C { + static internalValue = 123; + + @dec + static get element() { + return this.internalValue; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/getter/public/static/context-name-public.js b/test/language/statements/class/decorator/getter/public/static/context-name-public.js new file mode 100644 index 00000000000..0d1384272bd --- /dev/null +++ b/test/language/statements/class/decorator/getter/public/static/context-name-public.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-public.case +// - src/decorator/getters/standard/public/static/cls-decl.template +/*--- +description: Context name is correct for all types of public elements (public static getter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "element"); +} + + +class C { + static internalValue = 123; + + @dec + static get element() { + return this.internalValue; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/getter/public/static/context-private-true.js b/test/language/statements/class/decorator/getter/public/static/context-private-true.js new file mode 100644 index 00000000000..6ef250ca886 --- /dev/null +++ b/test/language/statements/class/decorator/getter/public/static/context-private-true.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-private-true.case +// - src/decorator/getters/standard/public/static/cls-decl.template +/*--- +description: Context `private` is false for all types of public elements (public static getter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.private, false); +} + + +class C { + static internalValue = 123; + + @dec + static get element() { + return this.internalValue; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/getter/public/static/context-static-true.js b/test/language/statements/class/decorator/getter/public/static/context-static-true.js new file mode 100644 index 00000000000..b5c93910b1b --- /dev/null +++ b/test/language/statements/class/decorator/getter/public/static/context-static-true.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-static-true.case +// - src/decorator/getters/standard/public/static/cls-decl.template +/*--- +description: Context `static` is false for all types of instance elements (public static getter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.static, true); +} + + +class C { + static internalValue = 123; + + @dec + static get element() { + return this.internalValue; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/getter/public/static/getter-deco-returns-replacement.js b/test/language/statements/class/decorator/getter/public/static/getter-deco-returns-replacement.js new file mode 100644 index 00000000000..6e2f314211a --- /dev/null +++ b/test/language/statements/class/decorator/getter/public/static/getter-deco-returns-replacement.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/getter-deco-returns-replacement.case +// - src/decorator/getters/standard/public/static/cls-decl.template +/*--- +description: Can replace a decorated getter with a new getter (public static getter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(value, context) { + + return function() { + assert.sameValue(value.call(this), 123); + + return 456; + }; +} + + +class C { + static internalValue = 123; + + @dec + + static get element() { + return this.internalValue; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/getter/public/static/getter-deco-returns-undefined.js b/test/language/statements/class/decorator/getter/public/static/getter-deco-returns-undefined.js new file mode 100644 index 00000000000..d31cf888737 --- /dev/null +++ b/test/language/statements/class/decorator/getter/public/static/getter-deco-returns-undefined.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/getter-deco-returns-undefined.case +// - src/decorator/getters/standard/public/static/cls-decl.template +/*--- +description: Decorator undefined return defaults to previous value (public static getter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec1(value, context) { + return function() { + assert.sameValue(value.call(this), 123); + + return 456; + }; +} + +function dec2() {} + + +class C { + static internalValue = 123; + + @dec2 @dec1 + + static get element() { + return this.internalValue; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/method/async/private/instance/context-kind-method.js b/test/language/statements/class/decorator/method/async/private/instance/context-kind-method.js new file mode 100644 index 00000000000..e06397fc9cc --- /dev/null +++ b/test/language/statements/class/decorator/method/async/private/instance/context-kind-method.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-method.case +// - src/decorator/methods/async/private/instance/cls-decl.template +/*--- +description: Context kind is the string "method" when decorating a method (private method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "method"); +} + + +class C { + @dec + async #element() { + return 123; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/statements/class/decorator/method/async/private/instance/method-async-deco-returns-replacement.js b/test/language/statements/class/decorator/method/async/private/instance/method-async-deco-returns-replacement.js new file mode 100644 index 00000000000..b2e82094aaf --- /dev/null +++ b/test/language/statements/class/decorator/method/async/private/instance/method-async-deco-returns-replacement.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-async-deco-returns-replacement.case +// - src/decorator/methods/async/private/instance/cls-decl.template +/*--- +description: Can replace a decorated method with a new method (private method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(value, context) { + assert(value() instanceof Promise); + + return () => 456; +} + + +class C { + @dec + + async #element() { + return 123; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/statements/class/decorator/method/async/private/instance/method-async-deco-returns-undefined.js b/test/language/statements/class/decorator/method/async/private/instance/method-async-deco-returns-undefined.js new file mode 100644 index 00000000000..86e681ced9d --- /dev/null +++ b/test/language/statements/class/decorator/method/async/private/instance/method-async-deco-returns-undefined.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-async-deco-returns-undefined.case +// - src/decorator/methods/async/private/instance/cls-decl.template +/*--- +description: Decorator undefined return defaults to previous value (private method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec1(value, context) { + assert(value() instanceof Promise); + + return () => 456; +} + +function dec2(value, context) { + assert.sameValue(value(), 456); +} + + +class C { + @dec2 @dec1 + + async #element() { + return 123; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/statements/class/decorator/method/async/private/static/context-kind-method.js b/test/language/statements/class/decorator/method/async/private/static/context-kind-method.js new file mode 100644 index 00000000000..a692a63058e --- /dev/null +++ b/test/language/statements/class/decorator/method/async/private/static/context-kind-method.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-method.case +// - src/decorator/methods/async/private/static/cls-decl.template +/*--- +description: Context kind is the string "method" when decorating a method (private static method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "method"); +} + + +class C { + @dec + static async #element() { + return 123; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/method/async/private/static/method-async-deco-returns-replacement.js b/test/language/statements/class/decorator/method/async/private/static/method-async-deco-returns-replacement.js new file mode 100644 index 00000000000..a0e3e51f4de --- /dev/null +++ b/test/language/statements/class/decorator/method/async/private/static/method-async-deco-returns-replacement.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-async-deco-returns-replacement.case +// - src/decorator/methods/async/private/static/cls-decl.template +/*--- +description: Can replace a decorated method with a new method (private static method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(value, context) { + assert(value() instanceof Promise); + + return () => 456; +} + + +class C { + @dec + + static async #element() { + return 123; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/statements/class/decorator/method/async/private/static/method-async-deco-returns-undefined.js b/test/language/statements/class/decorator/method/async/private/static/method-async-deco-returns-undefined.js new file mode 100644 index 00000000000..495bf355f0f --- /dev/null +++ b/test/language/statements/class/decorator/method/async/private/static/method-async-deco-returns-undefined.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-async-deco-returns-undefined.case +// - src/decorator/methods/async/private/static/cls-decl.template +/*--- +description: Decorator undefined return defaults to previous value (private static method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec1(value, context) { + assert(value() instanceof Promise); + + return () => 456; +} + +function dec2(value, context) { + assert.sameValue(value(), 456); +} + + +class C { + @dec2 @dec1 + + static async #element() { + return 123; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/statements/class/decorator/method/async/public/instance/context-kind-method.js b/test/language/statements/class/decorator/method/async/public/instance/context-kind-method.js new file mode 100644 index 00000000000..2115dd49443 --- /dev/null +++ b/test/language/statements/class/decorator/method/async/public/instance/context-kind-method.js @@ -0,0 +1,31 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-method.case +// - src/decorator/methods/async/public/instance/cls-decl.template +/*--- +description: Context kind is the string "method" when decorating a method (public method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "method"); +} + + +class C { + @dec + async element() { + return 123; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + + + diff --git a/test/language/statements/class/decorator/method/async/public/instance/method-async-deco-returns-replacement.js b/test/language/statements/class/decorator/method/async/public/instance/method-async-deco-returns-replacement.js new file mode 100644 index 00000000000..efa443f5271 --- /dev/null +++ b/test/language/statements/class/decorator/method/async/public/instance/method-async-deco-returns-replacement.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-async-deco-returns-replacement.case +// - src/decorator/methods/async/public/instance/cls-decl.template +/*--- +description: Can replace a decorated method with a new method (public method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(value, context) { + assert(value() instanceof Promise); + + return () => 456; +} + + +class C { + @dec + + async element() { + return 123; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement()(), 456); + diff --git a/test/language/statements/class/decorator/method/async/public/instance/method-async-deco-returns-undefined.js b/test/language/statements/class/decorator/method/async/public/instance/method-async-deco-returns-undefined.js new file mode 100644 index 00000000000..6056414c5b9 --- /dev/null +++ b/test/language/statements/class/decorator/method/async/public/instance/method-async-deco-returns-undefined.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-async-deco-returns-undefined.case +// - src/decorator/methods/async/public/instance/cls-decl.template +/*--- +description: Decorator undefined return defaults to previous value (public method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec1(value, context) { + assert(value() instanceof Promise); + + return () => 456; +} + +function dec2(value, context) { + assert.sameValue(value(), 456); +} + + +class C { + @dec2 @dec1 + + async element() { + return 123; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement()(), 456); + diff --git a/test/language/statements/class/decorator/method/async/public/static/context-kind-method.js b/test/language/statements/class/decorator/method/async/public/static/context-kind-method.js new file mode 100644 index 00000000000..8c6b4686f25 --- /dev/null +++ b/test/language/statements/class/decorator/method/async/public/static/context-kind-method.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-method.case +// - src/decorator/methods/async/public/static/cls-decl.template +/*--- +description: Context kind is the string "method" when decorating a method (public static method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "method"); +} + + +class C { + @dec + static async element() { + return 123; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/method/async/public/static/method-async-deco-returns-replacement.js b/test/language/statements/class/decorator/method/async/public/static/method-async-deco-returns-replacement.js new file mode 100644 index 00000000000..5c6502f3fce --- /dev/null +++ b/test/language/statements/class/decorator/method/async/public/static/method-async-deco-returns-replacement.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-async-deco-returns-replacement.case +// - src/decorator/methods/async/public/static/cls-decl.template +/*--- +description: Can replace a decorated method with a new method (public static method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(value, context) { + assert(value() instanceof Promise); + + return () => 456; +} + + +class C { + @dec + + static async element() { + return 123; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/statements/class/decorator/method/async/public/static/method-async-deco-returns-undefined.js b/test/language/statements/class/decorator/method/async/public/static/method-async-deco-returns-undefined.js new file mode 100644 index 00000000000..d07df53cb3e --- /dev/null +++ b/test/language/statements/class/decorator/method/async/public/static/method-async-deco-returns-undefined.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-async-deco-returns-undefined.case +// - src/decorator/methods/async/public/static/cls-decl.template +/*--- +description: Decorator undefined return defaults to previous value (public static method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec1(value, context) { + assert(value() instanceof Promise); + + return () => 456; +} + +function dec2(value, context) { + assert.sameValue(value(), 456); +} + + +class C { + @dec2 @dec1 + + static async element() { + return 123; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/statements/class/decorator/method/error/private/instance/method-deco-returns-invalid.js b/test/language/statements/class/decorator/method/error/private/instance/method-deco-returns-invalid.js new file mode 100644 index 00000000000..9ee0a5634ef --- /dev/null +++ b/test/language/statements/class/decorator/method/error/private/instance/method-deco-returns-invalid.js @@ -0,0 +1,25 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-deco-returns-invalid.case +// - src/decorator/methods/error/private/instance/cls-decl.template +/*--- +description: Decorator can't return an invalid value (private method decorator evaluation error in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + return 123; +} + + +function evaluate() { + class C { + @dec + + #element() {} + } +} + +assert.throws(TypeError, evaluate); diff --git a/test/language/statements/class/decorator/method/error/private/static/method-deco-returns-invalid.js b/test/language/statements/class/decorator/method/error/private/static/method-deco-returns-invalid.js new file mode 100644 index 00000000000..039c88b5f86 --- /dev/null +++ b/test/language/statements/class/decorator/method/error/private/static/method-deco-returns-invalid.js @@ -0,0 +1,26 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-deco-returns-invalid.case +// - src/decorator/methods/error/private/static/cls-decl.template +/*--- +description: Decorator can't return an invalid value (private static method decorator evaluation error in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + return 123; +} + + +function evaluate() { + class C { + @dec + + static #element() {} + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/statements/class/decorator/method/error/public/instance/method-deco-returns-invalid.js b/test/language/statements/class/decorator/method/error/public/instance/method-deco-returns-invalid.js new file mode 100644 index 00000000000..21b7f610ea2 --- /dev/null +++ b/test/language/statements/class/decorator/method/error/public/instance/method-deco-returns-invalid.js @@ -0,0 +1,26 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-deco-returns-invalid.case +// - src/decorator/methods/error/public/instance/cls-decl.template +/*--- +description: Decorator can't return an invalid value (public method decorator evaluation error in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + return 123; +} + + +function evaluate() { + class C { + @dec + + element() {} + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/statements/class/decorator/method/error/public/static/method-deco-returns-invalid.js b/test/language/statements/class/decorator/method/error/public/static/method-deco-returns-invalid.js new file mode 100644 index 00000000000..4603bea3b9e --- /dev/null +++ b/test/language/statements/class/decorator/method/error/public/static/method-deco-returns-invalid.js @@ -0,0 +1,26 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-deco-returns-invalid.case +// - src/decorator/methods/error/public/static/cls-decl.template +/*--- +description: Decorator can't return an invalid value (public static method decorator evaluation error in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + return 123; +} + + +function evaluate() { + class C { + @dec + + static element() {} + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/statements/class/decorator/method/private/instance/context-access-get.js b/test/language/statements/class/decorator/method/private/instance/context-access-get.js new file mode 100644 index 00000000000..b9be417862a --- /dev/null +++ b/test/language/statements/class/decorator/method/private/instance/context-access-get.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-get.case +// - src/decorator/methods/standard/private/instance/cls-decl.template +/*--- +description: Context access `get` works on all gettable types of values (private method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +class C { + @dec + + #element() { + return 123; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), access.get(classOrInstance)); diff --git a/test/language/statements/class/decorator/method/private/instance/context-kind-method.js b/test/language/statements/class/decorator/method/private/instance/context-kind-method.js new file mode 100644 index 00000000000..1bc25e1c84f --- /dev/null +++ b/test/language/statements/class/decorator/method/private/instance/context-kind-method.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-method.case +// - src/decorator/methods/standard/private/instance/cls-decl.template +/*--- +description: Context kind is the string "method" when decorating a method (private method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "method"); +} + + +class C { + @dec + #element() { + return 123; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/statements/class/decorator/method/private/instance/context-name-private.js b/test/language/statements/class/decorator/method/private/instance/context-name-private.js new file mode 100644 index 00000000000..1b1b7862be3 --- /dev/null +++ b/test/language/statements/class/decorator/method/private/instance/context-name-private.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-private.case +// - src/decorator/methods/standard/private/instance/cls-decl.template +/*--- +description: Context name is correct for all types of private elements (private method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "#element"); +} + + +class C { + @dec + #element() { + return 123; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/statements/class/decorator/method/private/instance/context-private-false.js b/test/language/statements/class/decorator/method/private/instance/context-private-false.js new file mode 100644 index 00000000000..0aef276e681 --- /dev/null +++ b/test/language/statements/class/decorator/method/private/instance/context-private-false.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-private-false.case +// - src/decorator/methods/standard/private/instance/cls-decl.template +/*--- +description: Context `private` is true for all types of private elements (private method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.private, true); +} + + +class C { + @dec + #element() { + return 123; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/statements/class/decorator/method/private/instance/context-static-false.js b/test/language/statements/class/decorator/method/private/instance/context-static-false.js new file mode 100644 index 00000000000..46bec735cb7 --- /dev/null +++ b/test/language/statements/class/decorator/method/private/instance/context-static-false.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-static-false.case +// - src/decorator/methods/standard/private/instance/cls-decl.template +/*--- +description: Context `static` is false for all types of instance elements (private method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.static, false); +} + + +class C { + @dec + #element() { + return 123; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/statements/class/decorator/method/private/instance/decorator-order-application-method-and-class.js b/test/language/statements/class/decorator/method/private/instance/decorator-order-application-method-and-class.js new file mode 100644 index 00000000000..f6cb84dbf13 --- /dev/null +++ b/test/language/statements/class/decorator/method/private/instance/decorator-order-application-method-and-class.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-order-application-method-and-class.case +// - src/decorator/methods/standard/private/instance/cls-decl.template +/*--- +description: Order of decorator application for elements without initializers (private method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +var ord = []; + +function pushOrd(applyOrd, extraInitOrd) { + return (value, context) => { + ord.push(applyOrd); + context.addInitializer(() => ord.push(extraInitOrd)); + } +} + + +class C { + @pushOrd(1, 3) + @pushOrd(0, 2) + + #element() { + return 123; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + +assert.sameValue(ord.length, 4); +ord.forEach(assert.sameValue); diff --git a/test/language/statements/class/decorator/method/private/instance/method-deco-returns-replacement.js b/test/language/statements/class/decorator/method/private/instance/method-deco-returns-replacement.js new file mode 100644 index 00000000000..14f5e2aff84 --- /dev/null +++ b/test/language/statements/class/decorator/method/private/instance/method-deco-returns-replacement.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-deco-returns-replacement.case +// - src/decorator/methods/standard/private/instance/cls-decl.template +/*--- +description: Can replace a decorated method with a new method (private method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(value, context) { + assert.sameValue(value(), 123); + + return () => 456; +} + + +class C { + @dec + + #element() { + return 123; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/statements/class/decorator/method/private/instance/method-deco-returns-undefined.js b/test/language/statements/class/decorator/method/private/instance/method-deco-returns-undefined.js new file mode 100644 index 00000000000..65a16a4e63e --- /dev/null +++ b/test/language/statements/class/decorator/method/private/instance/method-deco-returns-undefined.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-deco-returns-undefined.case +// - src/decorator/methods/standard/private/instance/cls-decl.template +/*--- +description: Decorator undefined return defaults to previous value (private method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec1(value, context) { + assert.sameValue(value(), 123); + + return () => 456; +} + +function dec2(value, context) { + assert.sameValue(value(), 456); +} + + +class C { + @dec2 @dec1 + + #element() { + return 123; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/statements/class/decorator/method/private/instance/method-generator-deco-returns-replacement.js b/test/language/statements/class/decorator/method/private/instance/method-generator-deco-returns-replacement.js new file mode 100644 index 00000000000..40bc4bf6f88 --- /dev/null +++ b/test/language/statements/class/decorator/method/private/instance/method-generator-deco-returns-replacement.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-generator-deco-returns-replacement.case +// - src/decorator/methods/generator/private/instance/cls-decl.template +/*--- +description: Can replace a decorated method with a new method (private method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(value, context) { + assert(value() instanceof Iterator, 'value is iterator'); + + return () => 456; +} + + +class C { + @dec + + * #element() { + return 123; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/statements/class/decorator/method/private/instance/method-generator-deco-returns-undefined.js b/test/language/statements/class/decorator/method/private/instance/method-generator-deco-returns-undefined.js new file mode 100644 index 00000000000..fa228150f53 --- /dev/null +++ b/test/language/statements/class/decorator/method/private/instance/method-generator-deco-returns-undefined.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-generator-deco-returns-undefined.case +// - src/decorator/methods/generator/private/instance/cls-decl.template +/*--- +description: Decorator undefined return defaults to previous value (private method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec1(value, context) { + assert(value() instanceof Iterator, 'value is iterator'); + + return () => 456; +} + +function dec2(value, context) { + assert.sameValue(value(), 456); +} + + +class C { + @dec2 @dec1 + + * #element() { + return 123; + } + + getElement() { + return this.#element; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/statements/class/decorator/method/private/static/context-access-get.js b/test/language/statements/class/decorator/method/private/static/context-access-get.js new file mode 100644 index 00000000000..085809da7da --- /dev/null +++ b/test/language/statements/class/decorator/method/private/static/context-access-get.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-get.case +// - src/decorator/methods/standard/private/static/cls-decl.template +/*--- +description: Context access `get` works on all gettable types of values (private static method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +class C { + @dec + + static #element() { + return 123; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), access.get(classOrInstance)); diff --git a/test/language/statements/class/decorator/method/private/static/context-kind-method.js b/test/language/statements/class/decorator/method/private/static/context-kind-method.js new file mode 100644 index 00000000000..9caf1ce8f45 --- /dev/null +++ b/test/language/statements/class/decorator/method/private/static/context-kind-method.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-method.case +// - src/decorator/methods/standard/private/static/cls-decl.template +/*--- +description: Context kind is the string "method" when decorating a method (private static method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "method"); +} + + +class C { + @dec + static #element() { + return 123; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/method/private/static/context-name-private.js b/test/language/statements/class/decorator/method/private/static/context-name-private.js new file mode 100644 index 00000000000..168dd534298 --- /dev/null +++ b/test/language/statements/class/decorator/method/private/static/context-name-private.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-private.case +// - src/decorator/methods/standard/private/static/cls-decl.template +/*--- +description: Context name is correct for all types of private elements (private static method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "#element"); +} + + +class C { + @dec + static #element() { + return 123; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/method/private/static/context-private-false.js b/test/language/statements/class/decorator/method/private/static/context-private-false.js new file mode 100644 index 00000000000..27fca44d807 --- /dev/null +++ b/test/language/statements/class/decorator/method/private/static/context-private-false.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-private-false.case +// - src/decorator/methods/standard/private/static/cls-decl.template +/*--- +description: Context `private` is true for all types of private elements (private static method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.private, true); +} + + +class C { + @dec + static #element() { + return 123; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/method/private/static/context-static-true.js b/test/language/statements/class/decorator/method/private/static/context-static-true.js new file mode 100644 index 00000000000..142508abe17 --- /dev/null +++ b/test/language/statements/class/decorator/method/private/static/context-static-true.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-static-true.case +// - src/decorator/methods/standard/private/static/cls-decl.template +/*--- +description: Context `static` is false for all types of instance elements (private static method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.static, true); +} + + +class C { + @dec + static #element() { + return 123; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/method/private/static/decorator-order-application-method-and-class.js b/test/language/statements/class/decorator/method/private/static/decorator-order-application-method-and-class.js new file mode 100644 index 00000000000..f4f5ca40556 --- /dev/null +++ b/test/language/statements/class/decorator/method/private/static/decorator-order-application-method-and-class.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-order-application-method-and-class.case +// - src/decorator/methods/standard/private/static/cls-decl.template +/*--- +description: Order of decorator application for elements without initializers (private static method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +var ord = []; + +function pushOrd(applyOrd, extraInitOrd) { + return (value, context) => { + ord.push(applyOrd); + context.addInitializer(() => ord.push(extraInitOrd)); + } +} + + +class C { + @pushOrd(1, 3) + @pushOrd(0, 2) + + static #element() { + return 123; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + +assert.sameValue(ord.length, 4); +ord.forEach(assert.sameValue); diff --git a/test/language/statements/class/decorator/method/private/static/method-deco-returns-replacement.js b/test/language/statements/class/decorator/method/private/static/method-deco-returns-replacement.js new file mode 100644 index 00000000000..88c5aca31e5 --- /dev/null +++ b/test/language/statements/class/decorator/method/private/static/method-deco-returns-replacement.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-deco-returns-replacement.case +// - src/decorator/methods/standard/private/static/cls-decl.template +/*--- +description: Can replace a decorated method with a new method (private static method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(value, context) { + assert.sameValue(value(), 123); + + return () => 456; +} + + +class C { + @dec + + static #element() { + return 123; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/statements/class/decorator/method/private/static/method-deco-returns-undefined.js b/test/language/statements/class/decorator/method/private/static/method-deco-returns-undefined.js new file mode 100644 index 00000000000..db9b7efb16b --- /dev/null +++ b/test/language/statements/class/decorator/method/private/static/method-deco-returns-undefined.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-deco-returns-undefined.case +// - src/decorator/methods/standard/private/static/cls-decl.template +/*--- +description: Decorator undefined return defaults to previous value (private static method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec1(value, context) { + assert.sameValue(value(), 123); + + return () => 456; +} + +function dec2(value, context) { + assert.sameValue(value(), 456); +} + + +class C { + @dec2 @dec1 + + static #element() { + return 123; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/statements/class/decorator/method/private/static/method-generator-deco-returns-replacement.js b/test/language/statements/class/decorator/method/private/static/method-generator-deco-returns-replacement.js new file mode 100644 index 00000000000..733690b12c9 --- /dev/null +++ b/test/language/statements/class/decorator/method/private/static/method-generator-deco-returns-replacement.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-generator-deco-returns-replacement.case +// - src/decorator/methods/generator/private/static/cls-decl.template +/*--- +description: Can replace a decorated method with a new method (private static method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(value, context) { + assert(value() instanceof Iterator, 'value is iterator'); + + return () => 456; +} + + +class C { + @dec + + static * #element() { + return 123; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/statements/class/decorator/method/private/static/method-generator-deco-returns-undefined.js b/test/language/statements/class/decorator/method/private/static/method-generator-deco-returns-undefined.js new file mode 100644 index 00000000000..4d1d9bc6708 --- /dev/null +++ b/test/language/statements/class/decorator/method/private/static/method-generator-deco-returns-undefined.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-generator-deco-returns-undefined.case +// - src/decorator/methods/generator/private/static/cls-decl.template +/*--- +description: Decorator undefined return defaults to previous value (private static method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec1(value, context) { + assert(value() instanceof Iterator, 'value is iterator'); + + return () => 456; +} + +function dec2(value, context) { + assert.sameValue(value(), 456); +} + + +class C { + @dec2 @dec1 + + static * #element() { + return 123; + } + + static getElement() { + return this.#element; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/statements/class/decorator/method/public/instance/context-access-get.js b/test/language/statements/class/decorator/method/public/instance/context-access-get.js new file mode 100644 index 00000000000..3fb24561f47 --- /dev/null +++ b/test/language/statements/class/decorator/method/public/instance/context-access-get.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-get.case +// - src/decorator/methods/standard/public/instance/cls-decl.template +/*--- +description: Context access `get` works on all gettable types of values (public method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +class C { + @dec + + element() { + return 123; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), access.get(classOrInstance)); + diff --git a/test/language/statements/class/decorator/method/public/instance/context-kind-method.js b/test/language/statements/class/decorator/method/public/instance/context-kind-method.js new file mode 100644 index 00000000000..092ee415333 --- /dev/null +++ b/test/language/statements/class/decorator/method/public/instance/context-kind-method.js @@ -0,0 +1,31 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-method.case +// - src/decorator/methods/standard/public/instance/cls-decl.template +/*--- +description: Context kind is the string "method" when decorating a method (public method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "method"); +} + + +class C { + @dec + element() { + return 123; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + + + diff --git a/test/language/statements/class/decorator/method/public/instance/context-name-public.js b/test/language/statements/class/decorator/method/public/instance/context-name-public.js new file mode 100644 index 00000000000..1947f1f9797 --- /dev/null +++ b/test/language/statements/class/decorator/method/public/instance/context-name-public.js @@ -0,0 +1,31 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-public.case +// - src/decorator/methods/standard/public/instance/cls-decl.template +/*--- +description: Context name is correct for all types of public elements (public method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "element"); +} + + +class C { + @dec + element() { + return 123; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + + + diff --git a/test/language/statements/class/decorator/method/public/instance/context-private-true.js b/test/language/statements/class/decorator/method/public/instance/context-private-true.js new file mode 100644 index 00000000000..4956678f48c --- /dev/null +++ b/test/language/statements/class/decorator/method/public/instance/context-private-true.js @@ -0,0 +1,31 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-private-true.case +// - src/decorator/methods/standard/public/instance/cls-decl.template +/*--- +description: Context `private` is false for all types of public elements (public method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.private, false); +} + + +class C { + @dec + element() { + return 123; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + + + diff --git a/test/language/statements/class/decorator/method/public/instance/context-static-false.js b/test/language/statements/class/decorator/method/public/instance/context-static-false.js new file mode 100644 index 00000000000..080e8cf3b2e --- /dev/null +++ b/test/language/statements/class/decorator/method/public/instance/context-static-false.js @@ -0,0 +1,31 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-static-false.case +// - src/decorator/methods/standard/public/instance/cls-decl.template +/*--- +description: Context `static` is false for all types of instance elements (public method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.static, false); +} + + +class C { + @dec + element() { + return 123; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + + + diff --git a/test/language/statements/class/decorator/method/public/instance/decorator-order-application-method-and-class.js b/test/language/statements/class/decorator/method/public/instance/decorator-order-application-method-and-class.js new file mode 100644 index 00000000000..9841bc12720 --- /dev/null +++ b/test/language/statements/class/decorator/method/public/instance/decorator-order-application-method-and-class.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-order-application-method-and-class.case +// - src/decorator/methods/standard/public/instance/cls-decl.template +/*--- +description: Order of decorator application for elements without initializers (public method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +var ord = []; + +function pushOrd(applyOrd, extraInitOrd) { + return (value, context) => { + ord.push(applyOrd); + context.addInitializer(() => ord.push(extraInitOrd)); + } +} + + +class C { + @pushOrd(1, 3) + @pushOrd(0, 2) + + element() { + return 123; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + +assert.sameValue(ord.length, 4); +ord.forEach(assert.sameValue); + diff --git a/test/language/statements/class/decorator/method/public/instance/method-deco-returns-replacement.js b/test/language/statements/class/decorator/method/public/instance/method-deco-returns-replacement.js new file mode 100644 index 00000000000..1d015dd8ab1 --- /dev/null +++ b/test/language/statements/class/decorator/method/public/instance/method-deco-returns-replacement.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-deco-returns-replacement.case +// - src/decorator/methods/standard/public/instance/cls-decl.template +/*--- +description: Can replace a decorated method with a new method (public method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(value, context) { + assert.sameValue(value(), 123); + + return () => 456; +} + + +class C { + @dec + + element() { + return 123; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement()(), 456); + diff --git a/test/language/statements/class/decorator/method/public/instance/method-deco-returns-undefined.js b/test/language/statements/class/decorator/method/public/instance/method-deco-returns-undefined.js new file mode 100644 index 00000000000..9986d0840df --- /dev/null +++ b/test/language/statements/class/decorator/method/public/instance/method-deco-returns-undefined.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-deco-returns-undefined.case +// - src/decorator/methods/standard/public/instance/cls-decl.template +/*--- +description: Decorator undefined return defaults to previous value (public method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec1(value, context) { + assert.sameValue(value(), 123); + + return () => 456; +} + +function dec2(value, context) { + assert.sameValue(value(), 456); +} + + +class C { + @dec2 @dec1 + + element() { + return 123; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement()(), 456); + diff --git a/test/language/statements/class/decorator/method/public/instance/method-generator-deco-returns-replacement.js b/test/language/statements/class/decorator/method/public/instance/method-generator-deco-returns-replacement.js new file mode 100644 index 00000000000..a04d385669f --- /dev/null +++ b/test/language/statements/class/decorator/method/public/instance/method-generator-deco-returns-replacement.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-generator-deco-returns-replacement.case +// - src/decorator/methods/generator/public/instance/cls-decl.template +/*--- +description: Can replace a decorated method with a new method (public method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(value, context) { + assert(value() instanceof Iterator, 'value is iterator'); + + return () => 456; +} + + +class C { + @dec + + * element() { + return 123; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement()(), 456); + diff --git a/test/language/statements/class/decorator/method/public/instance/method-generator-deco-returns-undefined.js b/test/language/statements/class/decorator/method/public/instance/method-generator-deco-returns-undefined.js new file mode 100644 index 00000000000..5877922631c --- /dev/null +++ b/test/language/statements/class/decorator/method/public/instance/method-generator-deco-returns-undefined.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-generator-deco-returns-undefined.case +// - src/decorator/methods/generator/public/instance/cls-decl.template +/*--- +description: Decorator undefined return defaults to previous value (public method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec1(value, context) { + assert(value() instanceof Iterator, 'value is iterator'); + + return () => 456; +} + +function dec2(value, context) { + assert.sameValue(value(), 456); +} + + +class C { + @dec2 @dec1 + + * element() { + return 123; + } + + getElement() { + return this.element; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement()(), 456); + diff --git a/test/language/statements/class/decorator/method/public/static/context-access-get.js b/test/language/statements/class/decorator/method/public/static/context-access-get.js new file mode 100644 index 00000000000..5cb86ff6854 --- /dev/null +++ b/test/language/statements/class/decorator/method/public/static/context-access-get.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-get.case +// - src/decorator/methods/standard/public/static/cls-decl.template +/*--- +description: Context access `get` works on all gettable types of values (public static method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + + +class C { + @dec + + static element() { + return 123; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), access.get(classOrInstance)); diff --git a/test/language/statements/class/decorator/method/public/static/context-kind-method.js b/test/language/statements/class/decorator/method/public/static/context-kind-method.js new file mode 100644 index 00000000000..1464cab19ef --- /dev/null +++ b/test/language/statements/class/decorator/method/public/static/context-kind-method.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-method.case +// - src/decorator/methods/standard/public/static/cls-decl.template +/*--- +description: Context kind is the string "method" when decorating a method (public static method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "method"); +} + + +class C { + @dec + static element() { + return 123; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/method/public/static/context-name-public.js b/test/language/statements/class/decorator/method/public/static/context-name-public.js new file mode 100644 index 00000000000..0752f4c2a36 --- /dev/null +++ b/test/language/statements/class/decorator/method/public/static/context-name-public.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-public.case +// - src/decorator/methods/standard/public/static/cls-decl.template +/*--- +description: Context name is correct for all types of public elements (public static method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "element"); +} + + +class C { + @dec + static element() { + return 123; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/method/public/static/context-private-true.js b/test/language/statements/class/decorator/method/public/static/context-private-true.js new file mode 100644 index 00000000000..e006464b45a --- /dev/null +++ b/test/language/statements/class/decorator/method/public/static/context-private-true.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-private-true.case +// - src/decorator/methods/standard/public/static/cls-decl.template +/*--- +description: Context `private` is false for all types of public elements (public static method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.private, false); +} + + +class C { + @dec + static element() { + return 123; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/method/public/static/context-static-true.js b/test/language/statements/class/decorator/method/public/static/context-static-true.js new file mode 100644 index 00000000000..cf1a704ebad --- /dev/null +++ b/test/language/statements/class/decorator/method/public/static/context-static-true.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-static-true.case +// - src/decorator/methods/standard/public/static/cls-decl.template +/*--- +description: Context `static` is false for all types of instance elements (public static method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.static, true); +} + + +class C { + @dec + static element() { + return 123; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/method/public/static/decorator-order-application-method-and-class.js b/test/language/statements/class/decorator/method/public/static/decorator-order-application-method-and-class.js new file mode 100644 index 00000000000..e0786b8f489 --- /dev/null +++ b/test/language/statements/class/decorator/method/public/static/decorator-order-application-method-and-class.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-order-application-method-and-class.case +// - src/decorator/methods/standard/public/static/cls-decl.template +/*--- +description: Order of decorator application for elements without initializers (public static method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +var ord = []; + +function pushOrd(applyOrd, extraInitOrd) { + return (value, context) => { + ord.push(applyOrd); + context.addInitializer(() => ord.push(extraInitOrd)); + } +} + + +class C { + @pushOrd(1, 3) + @pushOrd(0, 2) + + static element() { + return 123; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + +assert.sameValue(ord.length, 4); +ord.forEach(assert.sameValue); diff --git a/test/language/statements/class/decorator/method/public/static/method-deco-returns-replacement.js b/test/language/statements/class/decorator/method/public/static/method-deco-returns-replacement.js new file mode 100644 index 00000000000..1d7ecf2a413 --- /dev/null +++ b/test/language/statements/class/decorator/method/public/static/method-deco-returns-replacement.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-deco-returns-replacement.case +// - src/decorator/methods/standard/public/static/cls-decl.template +/*--- +description: Can replace a decorated method with a new method (public static method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(value, context) { + assert.sameValue(value(), 123); + + return () => 456; +} + + +class C { + @dec + + static element() { + return 123; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/statements/class/decorator/method/public/static/method-deco-returns-undefined.js b/test/language/statements/class/decorator/method/public/static/method-deco-returns-undefined.js new file mode 100644 index 00000000000..78c5f7ce77e --- /dev/null +++ b/test/language/statements/class/decorator/method/public/static/method-deco-returns-undefined.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-deco-returns-undefined.case +// - src/decorator/methods/standard/public/static/cls-decl.template +/*--- +description: Decorator undefined return defaults to previous value (public static method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec1(value, context) { + assert.sameValue(value(), 123); + + return () => 456; +} + +function dec2(value, context) { + assert.sameValue(value(), 456); +} + + +class C { + @dec2 @dec1 + + static element() { + return 123; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/statements/class/decorator/method/public/static/method-generator-deco-returns-replacement.js b/test/language/statements/class/decorator/method/public/static/method-generator-deco-returns-replacement.js new file mode 100644 index 00000000000..750c94e02d7 --- /dev/null +++ b/test/language/statements/class/decorator/method/public/static/method-generator-deco-returns-replacement.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-generator-deco-returns-replacement.case +// - src/decorator/methods/generator/public/static/cls-decl.template +/*--- +description: Can replace a decorated method with a new method (public static method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(value, context) { + assert(value() instanceof Iterator, 'value is iterator'); + + return () => 456; +} + + +class C { + @dec + + static * element() { + return 123; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/statements/class/decorator/method/public/static/method-generator-deco-returns-undefined.js b/test/language/statements/class/decorator/method/public/static/method-generator-deco-returns-undefined.js new file mode 100644 index 00000000000..f1011ad71ae --- /dev/null +++ b/test/language/statements/class/decorator/method/public/static/method-generator-deco-returns-undefined.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/method-generator-deco-returns-undefined.case +// - src/decorator/methods/generator/public/static/cls-decl.template +/*--- +description: Decorator undefined return defaults to previous value (public static method decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec1(value, context) { + assert(value() instanceof Iterator, 'value is iterator'); + + return () => 456; +} + +function dec2(value, context) { + assert.sameValue(value(), 456); +} + + +class C { + @dec2 @dec1 + + static * element() { + return 123; + } + + static getElement() { + return this.element; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement()(), 456); diff --git a/test/language/statements/class/decorator/setter/error/private/instance/setter-deco-returns-invalid.js b/test/language/statements/class/decorator/setter/error/private/instance/setter-deco-returns-invalid.js new file mode 100644 index 00000000000..fce96240039 --- /dev/null +++ b/test/language/statements/class/decorator/setter/error/private/instance/setter-deco-returns-invalid.js @@ -0,0 +1,25 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/setter-deco-returns-invalid.case +// - src/decorator/setters/error/private/instance/cls-decl.template +/*--- +description: Decorator can't return an invalid value (private setter decorator evaluation error in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + return 123; +} + + +function evaluate() { + class C { + @dec + + set #element(value) {} + } +} + +assert.throws(TypeError, evaluate); diff --git a/test/language/statements/class/decorator/setter/error/private/static/setter-deco-returns-invalid.js b/test/language/statements/class/decorator/setter/error/private/static/setter-deco-returns-invalid.js new file mode 100644 index 00000000000..b0ad87edf2f --- /dev/null +++ b/test/language/statements/class/decorator/setter/error/private/static/setter-deco-returns-invalid.js @@ -0,0 +1,26 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/setter-deco-returns-invalid.case +// - src/decorator/setters/error/private/static/cls-decl.template +/*--- +description: Decorator can't return an invalid value (private static setter decorator evaluation error in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + return 123; +} + + +function evaluate() { + class C { + @dec + + static set #element(value) {} + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/statements/class/decorator/setter/error/public/instance/setter-deco-returns-invalid.js b/test/language/statements/class/decorator/setter/error/public/instance/setter-deco-returns-invalid.js new file mode 100644 index 00000000000..44a0f8ad262 --- /dev/null +++ b/test/language/statements/class/decorator/setter/error/public/instance/setter-deco-returns-invalid.js @@ -0,0 +1,26 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/setter-deco-returns-invalid.case +// - src/decorator/setters/error/public/instance/cls-decl.template +/*--- +description: Decorator can't return an invalid value (public setter decorator evaluation error in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + return 123; +} + + +function evaluate() { + class C { + @dec + + set element(value) {} + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/statements/class/decorator/setter/error/public/static/setter-deco-returns-invalid.js b/test/language/statements/class/decorator/setter/error/public/static/setter-deco-returns-invalid.js new file mode 100644 index 00000000000..3fc7c4f06e4 --- /dev/null +++ b/test/language/statements/class/decorator/setter/error/public/static/setter-deco-returns-invalid.js @@ -0,0 +1,26 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/setter-deco-returns-invalid.case +// - src/decorator/setters/error/public/static/cls-decl.template +/*--- +description: Decorator can't return an invalid value (public static setter decorator evaluation error in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + return 123; +} + + +function evaluate() { + class C { + @dec + + static set element(value) {} + } +} + +assert.throws(TypeError, evaluate); + diff --git a/test/language/statements/class/decorator/setter/private/instance/context-access-set.js b/test/language/statements/class/decorator/setter/private/instance/context-access-set.js new file mode 100644 index 00000000000..b2ccb972c6e --- /dev/null +++ b/test/language/statements/class/decorator/setter/private/instance/context-access-set.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-set.case +// - src/decorator/setters/standard/private/instance/cls-decl.template +/*--- +description: Context access `get` works on all gettable types of values (private setter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + +class C { + internalValue = 123; + + @dec + + set #element(value) { + this.internalValue = value; + } + + getElement() { + return this.internalValue; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/setter/private/instance/context-kind-setter.js b/test/language/statements/class/decorator/setter/private/instance/context-kind-setter.js new file mode 100644 index 00000000000..653cc057fa4 --- /dev/null +++ b/test/language/statements/class/decorator/setter/private/instance/context-kind-setter.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-setter.case +// - src/decorator/setters/standard/private/instance/cls-decl.template +/*--- +description: Context kind is the string "setter" when decorating a method (private setter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "setter"); +} + +class C { + internalValue = 123; + + @dec + set #element(value) { + this.internalValue = value; + } + + getElement() { + return this.internalValue; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/statements/class/decorator/setter/private/instance/context-name-private.js b/test/language/statements/class/decorator/setter/private/instance/context-name-private.js new file mode 100644 index 00000000000..5406e89ccb1 --- /dev/null +++ b/test/language/statements/class/decorator/setter/private/instance/context-name-private.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-private.case +// - src/decorator/setters/standard/private/instance/cls-decl.template +/*--- +description: Context name is correct for all types of private elements (private setter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "#element"); +} + +class C { + internalValue = 123; + + @dec + set #element(value) { + this.internalValue = value; + } + + getElement() { + return this.internalValue; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/statements/class/decorator/setter/private/instance/context-private-false.js b/test/language/statements/class/decorator/setter/private/instance/context-private-false.js new file mode 100644 index 00000000000..d9b69bca9e2 --- /dev/null +++ b/test/language/statements/class/decorator/setter/private/instance/context-private-false.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-private-false.case +// - src/decorator/setters/standard/private/instance/cls-decl.template +/*--- +description: Context `private` is true for all types of private elements (private setter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.private, true); +} + +class C { + internalValue = 123; + + @dec + set #element(value) { + this.internalValue = value; + } + + getElement() { + return this.internalValue; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/statements/class/decorator/setter/private/instance/context-static-false.js b/test/language/statements/class/decorator/setter/private/instance/context-static-false.js new file mode 100644 index 00000000000..6473f93b0fc --- /dev/null +++ b/test/language/statements/class/decorator/setter/private/instance/context-static-false.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-static-false.case +// - src/decorator/setters/standard/private/instance/cls-decl.template +/*--- +description: Context `static` is false for all types of instance elements (private setter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.static, false); +} + +class C { + internalValue = 123; + + @dec + set #element(value) { + this.internalValue = value; + } + + getElement() { + return this.internalValue; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + + diff --git a/test/language/statements/class/decorator/setter/private/instance/setter-deco-returns-replacement.js b/test/language/statements/class/decorator/setter/private/instance/setter-deco-returns-replacement.js new file mode 100644 index 00000000000..3377dd2ba4d --- /dev/null +++ b/test/language/statements/class/decorator/setter/private/instance/setter-deco-returns-replacement.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/setter-deco-returns-replacement.case +// - src/decorator/setters/standard/private/instance/cls-decl.template +/*--- +description: Can replace a decorated setter with a new setter (private setter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +function dec(set, context) { + return function (v) { + assert.sameValue(v, 456); + set.call(this, 789); + }; +} + +class C { + internalValue = 123; + + @dec + + set #element(value) { + this.internalValue = value; + } + + getElement() { + return this.internalValue; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 123); +classOrInstance.setElement(456); +assert.sameValue(classOrInstance.getElement(), 789); diff --git a/test/language/statements/class/decorator/setter/private/instance/setter-deco-returns-undefined.js b/test/language/statements/class/decorator/setter/private/instance/setter-deco-returns-undefined.js new file mode 100644 index 00000000000..7e6499c2ef3 --- /dev/null +++ b/test/language/statements/class/decorator/setter/private/instance/setter-deco-returns-undefined.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/setter-deco-returns-undefined.case +// - src/decorator/setters/standard/private/instance/cls-decl.template +/*--- +description: Decorator undefined return defaults to previous value (private setter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-methods-private] +flags: [generated] +---*/ + + +var value; + +function dec1(set, context) { + return function (v) { + assert.sameValue(v, 456); + set.call(this, 789); + }; +} + +function dec2(value, context) { + // do nothing +} + +class C { + internalValue = 123; + + @dec2 @dec1 + + set #element(value) { + this.internalValue = value; + } + + getElement() { + return this.internalValue; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 123); +classOrInstance.setElement(456); +assert.sameValue(classOrInstance.getElement(), 789); diff --git a/test/language/statements/class/decorator/setter/private/static/context-access-set.js b/test/language/statements/class/decorator/setter/private/static/context-access-set.js new file mode 100644 index 00000000000..83f8babf766 --- /dev/null +++ b/test/language/statements/class/decorator/setter/private/static/context-access-set.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-set.case +// - src/decorator/setters/standard/private/static/cls-decl.template +/*--- +description: Context access `get` works on all gettable types of values (private static setter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + +class C { + static internalValue = 123; + + @dec + + static set #element(value) { + this.internalValue = value; + } + + static getElement() { + return this.internalValue; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/setter/private/static/context-kind-setter.js b/test/language/statements/class/decorator/setter/private/static/context-kind-setter.js new file mode 100644 index 00000000000..8a6246abdc3 --- /dev/null +++ b/test/language/statements/class/decorator/setter/private/static/context-kind-setter.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-setter.case +// - src/decorator/setters/standard/private/static/cls-decl.template +/*--- +description: Context kind is the string "setter" when decorating a method (private static setter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "setter"); +} + +class C { + static internalValue = 123; + + @dec + static set #element(value) { + this.internalValue = value; + } + + static getElement() { + return this.internalValue; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/setter/private/static/context-name-private.js b/test/language/statements/class/decorator/setter/private/static/context-name-private.js new file mode 100644 index 00000000000..52e7063e2ef --- /dev/null +++ b/test/language/statements/class/decorator/setter/private/static/context-name-private.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-private.case +// - src/decorator/setters/standard/private/static/cls-decl.template +/*--- +description: Context name is correct for all types of private elements (private static setter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "#element"); +} + +class C { + static internalValue = 123; + + @dec + static set #element(value) { + this.internalValue = value; + } + + static getElement() { + return this.internalValue; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/setter/private/static/context-private-false.js b/test/language/statements/class/decorator/setter/private/static/context-private-false.js new file mode 100644 index 00000000000..bbc7cd2b216 --- /dev/null +++ b/test/language/statements/class/decorator/setter/private/static/context-private-false.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-private-false.case +// - src/decorator/setters/standard/private/static/cls-decl.template +/*--- +description: Context `private` is true for all types of private elements (private static setter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.private, true); +} + +class C { + static internalValue = 123; + + @dec + static set #element(value) { + this.internalValue = value; + } + + static getElement() { + return this.internalValue; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/setter/private/static/context-static-true.js b/test/language/statements/class/decorator/setter/private/static/context-static-true.js new file mode 100644 index 00000000000..e1583d34920 --- /dev/null +++ b/test/language/statements/class/decorator/setter/private/static/context-static-true.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-static-true.case +// - src/decorator/setters/standard/private/static/cls-decl.template +/*--- +description: Context `static` is false for all types of instance elements (private static setter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.static, true); +} + +class C { + static internalValue = 123; + + @dec + static set #element(value) { + this.internalValue = value; + } + + static getElement() { + return this.internalValue; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/setter/private/static/setter-deco-returns-replacement.js b/test/language/statements/class/decorator/setter/private/static/setter-deco-returns-replacement.js new file mode 100644 index 00000000000..cd9f947c1b0 --- /dev/null +++ b/test/language/statements/class/decorator/setter/private/static/setter-deco-returns-replacement.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/setter-deco-returns-replacement.case +// - src/decorator/setters/standard/private/static/cls-decl.template +/*--- +description: Can replace a decorated setter with a new setter (private static setter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +function dec(set, context) { + return function (v) { + assert.sameValue(v, 456); + set.call(this, 789); + }; +} + +class C { + static internalValue = 123; + + @dec + + static set #element(value) { + this.internalValue = value; + } + + static getElement() { + return this.internalValue; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 123); +classOrInstance.setElement(456); +assert.sameValue(classOrInstance.getElement(), 789); diff --git a/test/language/statements/class/decorator/setter/private/static/setter-deco-returns-undefined.js b/test/language/statements/class/decorator/setter/private/static/setter-deco-returns-undefined.js new file mode 100644 index 00000000000..5118708d38c --- /dev/null +++ b/test/language/statements/class/decorator/setter/private/static/setter-deco-returns-undefined.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/setter-deco-returns-undefined.case +// - src/decorator/setters/standard/private/static/cls-decl.template +/*--- +description: Decorator undefined return defaults to previous value (private static setter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class, class-static-methods-private] +flags: [generated] +---*/ + + +var value; + +function dec1(set, context) { + return function (v) { + assert.sameValue(v, 456); + set.call(this, 789); + }; +} + +function dec2(value, context) { + // do nothing +} + +class C { + static internalValue = 123; + + @dec2 @dec1 + + static set #element(value) { + this.internalValue = value; + } + + static getElement() { + return this.internalValue; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 123); +classOrInstance.setElement(456); +assert.sameValue(classOrInstance.getElement(), 789); diff --git a/test/language/statements/class/decorator/setter/public/instance/context-access-set.js b/test/language/statements/class/decorator/setter/public/instance/context-access-set.js new file mode 100644 index 00000000000..299cab2d64a --- /dev/null +++ b/test/language/statements/class/decorator/setter/public/instance/context-access-set.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-set.case +// - src/decorator/setters/standard/public/instance/cls-decl.template +/*--- +description: Context access `get` works on all gettable types of values (public setter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + +class C { + internalValue = 123; + + @dec + + set element(value) { + this.internalValue = value; + } + + getElement() { + return this.internalValue; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); + diff --git a/test/language/statements/class/decorator/setter/public/instance/context-kind-setter.js b/test/language/statements/class/decorator/setter/public/instance/context-kind-setter.js new file mode 100644 index 00000000000..68da3083e77 --- /dev/null +++ b/test/language/statements/class/decorator/setter/public/instance/context-kind-setter.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-setter.case +// - src/decorator/setters/standard/public/instance/cls-decl.template +/*--- +description: Context kind is the string "setter" when decorating a method (public setter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "setter"); +} + +class C { + internalValue = 123; + + @dec + set element(value) { + this.internalValue = value; + } + + getElement() { + return this.internalValue; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + + + diff --git a/test/language/statements/class/decorator/setter/public/instance/context-name-public.js b/test/language/statements/class/decorator/setter/public/instance/context-name-public.js new file mode 100644 index 00000000000..59708f8d10c --- /dev/null +++ b/test/language/statements/class/decorator/setter/public/instance/context-name-public.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-public.case +// - src/decorator/setters/standard/public/instance/cls-decl.template +/*--- +description: Context name is correct for all types of public elements (public setter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "element"); +} + +class C { + internalValue = 123; + + @dec + set element(value) { + this.internalValue = value; + } + + getElement() { + return this.internalValue; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + + + diff --git a/test/language/statements/class/decorator/setter/public/instance/context-private-true.js b/test/language/statements/class/decorator/setter/public/instance/context-private-true.js new file mode 100644 index 00000000000..ecbedadc4f3 --- /dev/null +++ b/test/language/statements/class/decorator/setter/public/instance/context-private-true.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-private-true.case +// - src/decorator/setters/standard/public/instance/cls-decl.template +/*--- +description: Context `private` is false for all types of public elements (public setter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.private, false); +} + +class C { + internalValue = 123; + + @dec + set element(value) { + this.internalValue = value; + } + + getElement() { + return this.internalValue; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + + + diff --git a/test/language/statements/class/decorator/setter/public/instance/context-static-false.js b/test/language/statements/class/decorator/setter/public/instance/context-static-false.js new file mode 100644 index 00000000000..494f9aa7e71 --- /dev/null +++ b/test/language/statements/class/decorator/setter/public/instance/context-static-false.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-static-false.case +// - src/decorator/setters/standard/public/instance/cls-decl.template +/*--- +description: Context `static` is false for all types of instance elements (public setter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.static, false); +} + +class C { + internalValue = 123; + + @dec + set element(value) { + this.internalValue = value; + } + + getElement() { + return this.internalValue; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + + + diff --git a/test/language/statements/class/decorator/setter/public/instance/setter-deco-returns-replacement.js b/test/language/statements/class/decorator/setter/public/instance/setter-deco-returns-replacement.js new file mode 100644 index 00000000000..28eb5a1c78f --- /dev/null +++ b/test/language/statements/class/decorator/setter/public/instance/setter-deco-returns-replacement.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/setter-deco-returns-replacement.case +// - src/decorator/setters/standard/public/instance/cls-decl.template +/*--- +description: Can replace a decorated setter with a new setter (public setter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(set, context) { + return function (v) { + assert.sameValue(v, 456); + set.call(this, 789); + }; +} + +class C { + internalValue = 123; + + @dec + + set element(value) { + this.internalValue = value; + } + + getElement() { + return this.internalValue; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 123); +classOrInstance.setElement(456); +assert.sameValue(classOrInstance.getElement(), 789); + diff --git a/test/language/statements/class/decorator/setter/public/instance/setter-deco-returns-undefined.js b/test/language/statements/class/decorator/setter/public/instance/setter-deco-returns-undefined.js new file mode 100644 index 00000000000..c2d89e2e298 --- /dev/null +++ b/test/language/statements/class/decorator/setter/public/instance/setter-deco-returns-undefined.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/setter-deco-returns-undefined.case +// - src/decorator/setters/standard/public/instance/cls-decl.template +/*--- +description: Decorator undefined return defaults to previous value (public setter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +var value; + +function dec1(set, context) { + return function (v) { + assert.sameValue(v, 456); + set.call(this, 789); + }; +} + +function dec2(value, context) { + // do nothing +} + +class C { + internalValue = 123; + + @dec2 @dec1 + + set element(value) { + this.internalValue = value; + } + + getElement() { + return this.internalValue; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +assert.sameValue(classOrInstance.getElement(), 123); +classOrInstance.setElement(456); +assert.sameValue(classOrInstance.getElement(), 789); + diff --git a/test/language/statements/class/decorator/setter/public/static/context-access-set.js b/test/language/statements/class/decorator/setter/public/static/context-access-set.js new file mode 100644 index 00000000000..910ad5bd95d --- /dev/null +++ b/test/language/statements/class/decorator/setter/public/static/context-access-set.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-access-set.case +// - src/decorator/setters/standard/public/static/cls-decl.template +/*--- +description: Context access `get` works on all gettable types of values (public static setter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +var access; + +function dec(_, context) { + access = context.access; +} + +class C { + static internalValue = 123; + + @dec + + static set element(value) { + this.internalValue = value; + } + + static getElement() { + return this.internalValue; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +access.set(classOrInstance, 456); +assert.sameValue(classOrInstance.getElement(), 456); diff --git a/test/language/statements/class/decorator/setter/public/static/context-kind-setter.js b/test/language/statements/class/decorator/setter/public/static/context-kind-setter.js new file mode 100644 index 00000000000..8bfb1d074cb --- /dev/null +++ b/test/language/statements/class/decorator/setter/public/static/context-kind-setter.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-kind-setter.case +// - src/decorator/setters/standard/public/static/cls-decl.template +/*--- +description: Context kind is the string "setter" when decorating a method (public static setter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "setter"); +} + +class C { + static internalValue = 123; + + @dec + static set element(value) { + this.internalValue = value; + } + + static getElement() { + return this.internalValue; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/setter/public/static/context-name-public.js b/test/language/statements/class/decorator/setter/public/static/context-name-public.js new file mode 100644 index 00000000000..e5750198543 --- /dev/null +++ b/test/language/statements/class/decorator/setter/public/static/context-name-public.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-name-public.case +// - src/decorator/setters/standard/public/static/cls-decl.template +/*--- +description: Context name is correct for all types of public elements (public static setter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.name, "element"); +} + +class C { + static internalValue = 123; + + @dec + static set element(value) { + this.internalValue = value; + } + + static getElement() { + return this.internalValue; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/setter/public/static/context-private-true.js b/test/language/statements/class/decorator/setter/public/static/context-private-true.js new file mode 100644 index 00000000000..68dd33ea990 --- /dev/null +++ b/test/language/statements/class/decorator/setter/public/static/context-private-true.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-private-true.case +// - src/decorator/setters/standard/public/static/cls-decl.template +/*--- +description: Context `private` is false for all types of public elements (public static setter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.private, false); +} + +class C { + static internalValue = 123; + + @dec + static set element(value) { + this.internalValue = value; + } + + static getElement() { + return this.internalValue; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/setter/public/static/context-static-true.js b/test/language/statements/class/decorator/setter/public/static/context-static-true.js new file mode 100644 index 00000000000..626b705b8c8 --- /dev/null +++ b/test/language/statements/class/decorator/setter/public/static/context-static-true.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/context-static-true.case +// - src/decorator/setters/standard/public/static/cls-decl.template +/*--- +description: Context `static` is false for all types of instance elements (public static setter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(_, context) { + assert.sameValue(context.static, true); +} + +class C { + static internalValue = 123; + + @dec + static set element(value) { + this.internalValue = value; + } + + static getElement() { + return this.internalValue; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + + diff --git a/test/language/statements/class/decorator/setter/public/static/setter-deco-returns-replacement.js b/test/language/statements/class/decorator/setter/public/static/setter-deco-returns-replacement.js new file mode 100644 index 00000000000..fa78b5b3927 --- /dev/null +++ b/test/language/statements/class/decorator/setter/public/static/setter-deco-returns-replacement.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/setter-deco-returns-replacement.case +// - src/decorator/setters/standard/public/static/cls-decl.template +/*--- +description: Can replace a decorated setter with a new setter (public static setter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +function dec(set, context) { + return function (v) { + assert.sameValue(v, 456); + set.call(this, 789); + }; +} + +class C { + static internalValue = 123; + + @dec + + static set element(value) { + this.internalValue = value; + } + + static getElement() { + return this.internalValue; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 123); +classOrInstance.setElement(456); +assert.sameValue(classOrInstance.getElement(), 789); diff --git a/test/language/statements/class/decorator/setter/public/static/setter-deco-returns-undefined.js b/test/language/statements/class/decorator/setter/public/static/setter-deco-returns-undefined.js new file mode 100644 index 00000000000..6c646fecd8c --- /dev/null +++ b/test/language/statements/class/decorator/setter/public/static/setter-deco-returns-undefined.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/setter-deco-returns-undefined.case +// - src/decorator/setters/standard/public/static/cls-decl.template +/*--- +description: Decorator undefined return defaults to previous value (public static setter decorator behavior in class declaration) +esid: prod-MethodDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +var value; + +function dec1(set, context) { + return function (v) { + assert.sameValue(v, 456); + set.call(this, 789); + }; +} + +function dec2(value, context) { + // do nothing +} + +class C { + static internalValue = 123; + + @dec2 @dec1 + + static set element(value) { + this.internalValue = value; + } + + static getElement() { + return this.internalValue; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +assert.sameValue(classOrInstance.getElement(), 123); +classOrInstance.setElement(456); +assert.sameValue(classOrInstance.getElement(), 789); From 15f73b9e318629384178d8dbcf487ac6f40521a8 Mon Sep 17 00:00:00 2001 From: Kristen Maevyn Date: Thu, 6 Jun 2024 09:48:10 -0400 Subject: [PATCH 3/3] TEMP: Autogenerated tests without templates --- .../class/decorator/field-context-kind.js | 33 +++++++ .../field-initializers-interleave.js | 45 ++++++++++ .../field-instance-initializer-order.js | 47 ++++++++++ .../class/decorator/field-received-value.js | 41 +++++++++ .../field-static-initializer-order.js | 45 ++++++++++ .../field-instance-initializer-order.js | 47 ++++++++++ .../class/decorator/field-context-kind.js | 33 +++++++ .../field-initializers-interleave.js | 45 ++++++++++ .../class/decorator/field-received-value.js | 41 +++++++++ .../field-static-initializer-order.js | 45 ++++++++++ .../valid/class-element-decorator-test-123.js | 87 +++++++++++++++++++ .../field-instance-initializer-order.js | 47 ++++++++++ 12 files changed, 556 insertions(+) create mode 100644 test/language/expressions/class/decorator/field-context-kind.js create mode 100644 test/language/expressions/class/decorator/field-initializers-interleave.js create mode 100644 test/language/expressions/class/decorator/field-instance-initializer-order.js create mode 100644 test/language/expressions/class/decorator/field-received-value.js create mode 100644 test/language/expressions/class/decorator/field-static-initializer-order.js create mode 100644 test/language/expressions/class/decorator/with-super-class/field-instance-initializer-order.js create mode 100644 test/language/statements/class/decorator/field-context-kind.js create mode 100644 test/language/statements/class/decorator/field-initializers-interleave.js create mode 100644 test/language/statements/class/decorator/field-received-value.js create mode 100644 test/language/statements/class/decorator/field-static-initializer-order.js create mode 100644 test/language/statements/class/decorator/syntax/valid/class-element-decorator-test-123.js create mode 100644 test/language/statements/class/decorator/with-super-class/field-instance-initializer-order.js diff --git a/test/language/expressions/class/decorator/field-context-kind.js b/test/language/expressions/class/decorator/field-context-kind.js new file mode 100644 index 00000000000..cc797186171 --- /dev/null +++ b/test/language/expressions/class/decorator/field-context-kind.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-context-kind.case +// - src/decorator/default/cls-expr.template +/*--- +description: Context kind is the string "field" when decorating a field (decorator usage in a class expression) +esid: prod-FieldDefinition +features: [decorators, class] +flags: [generated] +info: | + CreateDecoratorContextObject ( kind, name, initializers, decorationState [ , isStatic ] ) + + ... + + 6. Else if kind is field, then + a. Let kindStr be "field". + +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "field"); +} + + +var C = class { + @dec foo; + @dec bar = 123; + + @dec static foo; + @dec static bar = 123; +} + + diff --git a/test/language/expressions/class/decorator/field-initializers-interleave.js b/test/language/expressions/class/decorator/field-initializers-interleave.js new file mode 100644 index 00000000000..e25b5cc9e40 --- /dev/null +++ b/test/language/expressions/class/decorator/field-initializers-interleave.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-initializers-interleave.case +// - src/decorator/default/cls-expr.template +/*--- +description: Decorated field initializers are interleaved with undecorated fields (decorator usage in a class expression) +esid: prod-FieldDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +var ord = []; + +function pushOrd(evalOrd, applyOrd, initOrd, extraOrd) { + ord.push(evalOrd); + + return (value, context) => { + ord.push(applyOrd); + + context.addInitializer(() => ord.push(extraOrd)); + + return () => { + ord.push(initOrd); + } + } +} + + +var C = class { + @pushOrd(0, 5, 9, 12) + @pushOrd(1, 4, 10, 11) + foo = ord.push(8); + + bar = ord.push(13); + + @pushOrd(2, 7, 15, 18) + @pushOrd(3, 6, 16, 17) + baz = ord.push(14) + +} + +new C(); + +assert.sameValue(ord.length, 19); +ord.forEach(assert.sameValue); diff --git a/test/language/expressions/class/decorator/field-instance-initializer-order.js b/test/language/expressions/class/decorator/field-instance-initializer-order.js new file mode 100644 index 00000000000..b523be5f6bc --- /dev/null +++ b/test/language/expressions/class/decorator/field-instance-initializer-order.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-instance-initializer-order.case +// - src/decorator/with-super-class/cls-expr.template +/*--- +description: Decorated field instance initializers run after super, before constructor (decorator usage in a class expression) +esid: prod-FieldDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +var ord = []; + +function pushOrd(evalOrd, applyOrd, initOrd, extraOrd) { + ord.push(evalOrd); + + return (value, context) => { + ord.push(applyOrd); + + context.addInitializer(() => ord.push(extraOrd)); + + return () => { + ord.push(initOrd); + } + } +} + + +class B {} + +var C = class extends B { + @pushOrd(0, 3, 6, 9) + @pushOrd(1, 2, 7, 8) + foo = ord.push(5); + + constructor() { + ord.push(4); + super(); + ord.push(10) + } + +} + +new C(); + +assert.sameValue(ord.length, 11); +ord.forEach(assert.sameValue); diff --git a/test/language/expressions/class/decorator/field-received-value.js b/test/language/expressions/class/decorator/field-received-value.js new file mode 100644 index 00000000000..03514f06138 --- /dev/null +++ b/test/language/expressions/class/decorator/field-received-value.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-received-value.case +// - src/decorator/default/cls-expr.template +/*--- +description: Value passed to field decorators is undefined (decorator usage in a class expression) +esid: prod-FieldDefinition +features: [decorators, class] +flags: [generated] +info: | + ApplyDecoratorsToElementDefinition ( homeObject, elementRecord, extraInitializers, isStatic ) + + ... + + 5. For each element decoratorRecord of decorators, do + a. Let decorator be decoratorRecord.[[Decorator]]. + b. Let decoratorReceiver be decoratorRecord.[[Receiver]]. + c. Let decorationState be the Record { [[Finished]]: false }. + d. Let context be CreateDecoratorContextObject(kind, key, extraInitializers, decorationState, isStatic). + e. Let value be undefined. + + ... + + j. Let newValue be ? Call(decorator, decoratorReceiver, « value, context »). + +---*/ + + +function dec(value) { + assert.sameValue(value, undefined); +} + + +var C = class { + @dec foo; + @dec bar = 123; + + @dec static foo; + @dec static bar = 123; +} + + diff --git a/test/language/expressions/class/decorator/field-static-initializer-order.js b/test/language/expressions/class/decorator/field-static-initializer-order.js new file mode 100644 index 00000000000..f4381f131fa --- /dev/null +++ b/test/language/expressions/class/decorator/field-static-initializer-order.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-static-initializer-order.case +// - src/decorator/default/cls-expr.template +/*--- +description: Decorated field static initializers interleave with static blocks (decorator usage in a class expression) +esid: prod-FieldDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +var ord = []; + +function pushOrd(evalOrd, applyOrd, initOrd, extraOrd) { + ord.push(evalOrd); + + return (value, context) => { + ord.push(applyOrd); + + context.addInitializer(() => ord.push(extraOrd)); + + return () => { + ord.push(initOrd); + } + } +} + + +var C = class { + static { + ord.push(4) + } + + @pushOrd(0, 3, 6, 9) + @pushOrd(1, 2, 7, 8) + static foo = ord.push(5); + + static { + ord.push(10) + } + +} + +assert.sameValue(ord.length, 11); +ord.forEach(assert.sameValue); diff --git a/test/language/expressions/class/decorator/with-super-class/field-instance-initializer-order.js b/test/language/expressions/class/decorator/with-super-class/field-instance-initializer-order.js new file mode 100644 index 00000000000..cb45161655d --- /dev/null +++ b/test/language/expressions/class/decorator/with-super-class/field-instance-initializer-order.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-instance-initializer-order.case +// - src/decorator/with-super-class/cls-expr.template +/*--- +description: Decorated field instance initializers run after super, before constructor (decorator usage in a class expression) +esid: prod-FieldDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +var ord = []; + +function pushOrd(evalOrd, applyOrd, initOrd, extraOrd) { + ord.push(evalOrd); + + return (value, context) => { + ord.push(applyOrd); + + context.addInitializer(() => ord.push(extraOrd)); + + return () => { + ord.push(initOrd); + } + } +} + + +class B {} + +var C = class extends B { + constructor() { + ord.push(4); + super(); + ord.push(10); + } + + @pushOrd(0, 3, 6, 9) + @pushOrd(1, 2, 7, 8) + foo = ord.push(5); + +} + +new C(); + +assert.sameValue(ord.length, 11); +ord.forEach(assert.sameValue); diff --git a/test/language/statements/class/decorator/field-context-kind.js b/test/language/statements/class/decorator/field-context-kind.js new file mode 100644 index 00000000000..4806f5736a4 --- /dev/null +++ b/test/language/statements/class/decorator/field-context-kind.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-context-kind.case +// - src/decorator/default/cls-decl.template +/*--- +description: Context kind is the string "field" when decorating a field (decorator usage in a class declaration) +esid: prod-FieldDefinition +features: [decorators, class] +flags: [generated] +info: | + CreateDecoratorContextObject ( kind, name, initializers, decorationState [ , isStatic ] ) + + ... + + 6. Else if kind is field, then + a. Let kindStr be "field". + +---*/ + + +function dec(_, context) { + assert.sameValue(context.kind, "field"); +} + + +class C { + @dec foo; + @dec bar = 123; + + @dec static foo; + @dec static bar = 123; +} + + diff --git a/test/language/statements/class/decorator/field-initializers-interleave.js b/test/language/statements/class/decorator/field-initializers-interleave.js new file mode 100644 index 00000000000..dd020b4436f --- /dev/null +++ b/test/language/statements/class/decorator/field-initializers-interleave.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-initializers-interleave.case +// - src/decorator/default/cls-decl.template +/*--- +description: Decorated field initializers are interleaved with undecorated fields (decorator usage in a class declaration) +esid: prod-FieldDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +var ord = []; + +function pushOrd(evalOrd, applyOrd, initOrd, extraOrd) { + ord.push(evalOrd); + + return (value, context) => { + ord.push(applyOrd); + + context.addInitializer(() => ord.push(extraOrd)); + + return () => { + ord.push(initOrd); + } + } +} + + +class C { + @pushOrd(0, 5, 9, 12) + @pushOrd(1, 4, 10, 11) + foo = ord.push(8); + + bar = ord.push(13); + + @pushOrd(2, 7, 15, 18) + @pushOrd(3, 6, 16, 17) + baz = ord.push(14) + +} + +new C(); + +assert.sameValue(ord.length, 19); +ord.forEach(assert.sameValue); diff --git a/test/language/statements/class/decorator/field-received-value.js b/test/language/statements/class/decorator/field-received-value.js new file mode 100644 index 00000000000..78fc927406c --- /dev/null +++ b/test/language/statements/class/decorator/field-received-value.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-received-value.case +// - src/decorator/default/cls-decl.template +/*--- +description: Value passed to field decorators is undefined (decorator usage in a class declaration) +esid: prod-FieldDefinition +features: [decorators, class] +flags: [generated] +info: | + ApplyDecoratorsToElementDefinition ( homeObject, elementRecord, extraInitializers, isStatic ) + + ... + + 5. For each element decoratorRecord of decorators, do + a. Let decorator be decoratorRecord.[[Decorator]]. + b. Let decoratorReceiver be decoratorRecord.[[Receiver]]. + c. Let decorationState be the Record { [[Finished]]: false }. + d. Let context be CreateDecoratorContextObject(kind, key, extraInitializers, decorationState, isStatic). + e. Let value be undefined. + + ... + + j. Let newValue be ? Call(decorator, decoratorReceiver, « value, context »). + +---*/ + + +function dec(value) { + assert.sameValue(value, undefined); +} + + +class C { + @dec foo; + @dec bar = 123; + + @dec static foo; + @dec static bar = 123; +} + + diff --git a/test/language/statements/class/decorator/field-static-initializer-order.js b/test/language/statements/class/decorator/field-static-initializer-order.js new file mode 100644 index 00000000000..69e1aef5dfa --- /dev/null +++ b/test/language/statements/class/decorator/field-static-initializer-order.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-static-initializer-order.case +// - src/decorator/default/cls-decl.template +/*--- +description: Decorated field static initializers interleave with static blocks (decorator usage in a class declaration) +esid: prod-FieldDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +var ord = []; + +function pushOrd(evalOrd, applyOrd, initOrd, extraOrd) { + ord.push(evalOrd); + + return (value, context) => { + ord.push(applyOrd); + + context.addInitializer(() => ord.push(extraOrd)); + + return () => { + ord.push(initOrd); + } + } +} + + +class C { + static { + ord.push(4) + } + + @pushOrd(0, 3, 6, 9) + @pushOrd(1, 2, 7, 8) + static foo = ord.push(5); + + static { + ord.push(10) + } + +} + +assert.sameValue(ord.length, 11); +ord.forEach(assert.sameValue); diff --git a/test/language/statements/class/decorator/syntax/valid/class-element-decorator-test-123.js b/test/language/statements/class/decorator/syntax/valid/class-element-decorator-test-123.js new file mode 100644 index 00000000000..ecbadc5c6c4 --- /dev/null +++ b/test/language/statements/class/decorator/syntax/valid/class-element-decorator-test-123.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-test-123.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; +} diff --git a/test/language/statements/class/decorator/with-super-class/field-instance-initializer-order.js b/test/language/statements/class/decorator/with-super-class/field-instance-initializer-order.js new file mode 100644 index 00000000000..cbdb9316077 --- /dev/null +++ b/test/language/statements/class/decorator/with-super-class/field-instance-initializer-order.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-instance-initializer-order.case +// - src/decorator/with-super-class/cls-decl.template +/*--- +description: Decorated field instance initializers run after super, before constructor (decorator usage in a class declaration) +esid: prod-FieldDefinition +features: [decorators, class] +flags: [generated] +---*/ + + +var ord = []; + +function pushOrd(evalOrd, applyOrd, initOrd, extraOrd) { + ord.push(evalOrd); + + return (value, context) => { + ord.push(applyOrd); + + context.addInitializer(() => ord.push(extraOrd)); + + return () => { + ord.push(initOrd); + } + } +} + + +class B {} + +class C extends B { + constructor() { + ord.push(4); + super(); + ord.push(10); + } + + @pushOrd(0, 3, 6, 9) + @pushOrd(1, 2, 7, 8) + foo = ord.push(5); + +} + +new C(); + +assert.sameValue(ord.length, 11); +ord.forEach(assert.sameValue);