From e3d0889009dee10e03a8195c462894ff1e9b7cbc Mon Sep 17 00:00:00 2001 From: Dunqing <29533304+Dunqing@users.noreply.github.com> Date: Wed, 18 Dec 2024 10:25:21 +0000 Subject: [PATCH] test(transformer/class-properties): add static super tagged template test (#7964) I just found that we don't need to transform `TaggedTemplateExpression` because its `tag` can be transformed by `transform_static_member_expression` and `transform_computed_member_expression` --- tasks/transform_conformance/snapshots/oxc.snap.md | 7 +++++-- .../snapshots/oxc_exec.snap.md | 8 +++++++- .../fixtures/static-super-tagged-template/exec.js | 11 +++++++++++ .../fixtures/static-super-tagged-template/input.js | 11 +++++++++++ .../fixtures/static-super-tagged-template/output.js | 13 +++++++++++++ 5 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 tasks/transform_conformance/tests/babel-plugin-transform-class-properties/test/fixtures/static-super-tagged-template/exec.js create mode 100644 tasks/transform_conformance/tests/babel-plugin-transform-class-properties/test/fixtures/static-super-tagged-template/input.js create mode 100644 tasks/transform_conformance/tests/babel-plugin-transform-class-properties/test/fixtures/static-super-tagged-template/output.js diff --git a/tasks/transform_conformance/snapshots/oxc.snap.md b/tasks/transform_conformance/snapshots/oxc.snap.md index b44ec0405f484..f99f561be09c5 100644 --- a/tasks/transform_conformance/snapshots/oxc.snap.md +++ b/tasks/transform_conformance/snapshots/oxc.snap.md @@ -1,6 +1,6 @@ commit: 54a8389f -Passed: 112/126 +Passed: 112/127 # All Passed: * babel-plugin-transform-class-static-block @@ -16,7 +16,10 @@ Passed: 112/126 * regexp -# babel-plugin-transform-class-properties (13/15) +# babel-plugin-transform-class-properties (13/16) +* static-super-tagged-template/input.js +x Output mismatch + * typescript/optional-call/input.ts Symbol reference IDs mismatch for "X": after transform: SymbolId(0): [ReferenceId(0), ReferenceId(2), ReferenceId(6), ReferenceId(11), ReferenceId(16)] diff --git a/tasks/transform_conformance/snapshots/oxc_exec.snap.md b/tasks/transform_conformance/snapshots/oxc_exec.snap.md index 23e62427ba1c3..e20ce14fbc024 100644 --- a/tasks/transform_conformance/snapshots/oxc_exec.snap.md +++ b/tasks/transform_conformance/snapshots/oxc_exec.snap.md @@ -2,4 +2,10 @@ commit: 54a8389f node: v22.12.0 -Passed: 3 of 3 (100.00%) +Passed: 3 of 4 (75.00%) + +Failures: + +./fixtures/oxc/babel-plugin-transform-class-properties-test-fixtures-static-super-tagged-template-exec.test.js +AssertionError: expected undefined to be [Function C] // Object.is equality + at ./tasks/transform_conformance/fixtures/oxc/babel-plugin-transform-class-properties-test-fixtures-static-super-tagged-template-exec.test.js:15:17 diff --git a/tasks/transform_conformance/tests/babel-plugin-transform-class-properties/test/fixtures/static-super-tagged-template/exec.js b/tasks/transform_conformance/tests/babel-plugin-transform-class-properties/test/fixtures/static-super-tagged-template/exec.js new file mode 100644 index 0000000000000..9b3ff167106aa --- /dev/null +++ b/tasks/transform_conformance/tests/babel-plugin-transform-class-properties/test/fixtures/static-super-tagged-template/exec.js @@ -0,0 +1,11 @@ +class S { + static method() { + return this; + } +} + +class C extends S { + static prop = super.method`xyz`; +} + +expect(C.prop).toBe(C); diff --git a/tasks/transform_conformance/tests/babel-plugin-transform-class-properties/test/fixtures/static-super-tagged-template/input.js b/tasks/transform_conformance/tests/babel-plugin-transform-class-properties/test/fixtures/static-super-tagged-template/input.js new file mode 100644 index 0000000000000..9b3ff167106aa --- /dev/null +++ b/tasks/transform_conformance/tests/babel-plugin-transform-class-properties/test/fixtures/static-super-tagged-template/input.js @@ -0,0 +1,11 @@ +class S { + static method() { + return this; + } +} + +class C extends S { + static prop = super.method`xyz`; +} + +expect(C.prop).toBe(C); diff --git a/tasks/transform_conformance/tests/babel-plugin-transform-class-properties/test/fixtures/static-super-tagged-template/output.js b/tasks/transform_conformance/tests/babel-plugin-transform-class-properties/test/fixtures/static-super-tagged-template/output.js new file mode 100644 index 0000000000000..0f64a58ada976 --- /dev/null +++ b/tasks/transform_conformance/tests/babel-plugin-transform-class-properties/test/fixtures/static-super-tagged-template/output.js @@ -0,0 +1,13 @@ +var _C; + +class S { + static method() { + return this; + } +} + +class C extends S {} +_C = C; +babelHelpers.defineProperty(C, "prop", babelHelpers.superPropGet(_C, "method", _C).bind(_C)`xyz`); + +expect(C.prop).toBe(C);