From 0c38523664ecc2619dfced16e412c10d96641300 Mon Sep 17 00:00:00 2001 From: overlookmotel Date: Mon, 9 Dec 2024 15:11:05 +0000 Subject: [PATCH] test(transformer/logic-assignment-operator): add more tests --- .../snapshots/oxc.snap.md | 3 ++- .../test/fixtures/computed-props/input.js | 22 +++++++++++++++++++ .../test/fixtures/computed-props/output.js | 15 +++++++++++++ .../test/fixtures/options.json | 5 +++++ 4 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 tasks/transform_conformance/tests/babel-plugin-transform-logical-assignment-operators/test/fixtures/computed-props/input.js create mode 100644 tasks/transform_conformance/tests/babel-plugin-transform-logical-assignment-operators/test/fixtures/computed-props/output.js create mode 100644 tasks/transform_conformance/tests/babel-plugin-transform-logical-assignment-operators/test/fixtures/options.json diff --git a/tasks/transform_conformance/snapshots/oxc.snap.md b/tasks/transform_conformance/snapshots/oxc.snap.md index 50fe5267aa7985..347f8f4e3c3d7d 100644 --- a/tasks/transform_conformance/snapshots/oxc.snap.md +++ b/tasks/transform_conformance/snapshots/oxc.snap.md @@ -1,9 +1,10 @@ commit: 54a8389f -Passed: 96/108 +Passed: 97/109 # All Passed: * babel-plugin-transform-class-static-block +* babel-plugin-transform-logical-assignment-operators * babel-plugin-transform-nullish-coalescing-operator * babel-plugin-transform-optional-catch-binding * babel-plugin-transform-async-generator-functions diff --git a/tasks/transform_conformance/tests/babel-plugin-transform-logical-assignment-operators/test/fixtures/computed-props/input.js b/tasks/transform_conformance/tests/babel-plugin-transform-logical-assignment-operators/test/fixtures/computed-props/input.js new file mode 100644 index 00000000000000..542c69dfc35041 --- /dev/null +++ b/tasks/transform_conformance/tests/babel-plugin-transform-logical-assignment-operators/test/fixtures/computed-props/input.js @@ -0,0 +1,22 @@ +var _unboundProp, + _unboundObj, + _unboundObj2, + _unboundProp2, + _boundObj$prop, + _boundObj$prop2, + _unboundProp3, + _unboundProp4; + +let boundObj, boundProp; + +boundObj[boundProp] && (boundObj[boundProp] = 1); +boundObj[(_unboundProp = unboundProp)] && (boundObj[_unboundProp] = 2); + +(_unboundObj = unboundObj)[boundProp] && (_unboundObj[boundProp] = 3); +(_unboundObj2 = unboundObj)[(_unboundProp2 = unboundProp)] && (_unboundObj2[_unboundProp2] = 4); + +(_boundObj$prop = boundObj.prop)[boundProp] && (_boundObj$prop[boundProp] = 5); +(_boundObj$prop2 = boundObj.prop)[(_unboundProp3 = unboundProp)] && (_boundObj$prop2[_unboundProp3] = 6); + +this[boundProp] && (this[boundProp] = 7); +this[(_unboundProp4 = unboundProp)] && (this[_unboundProp4] = 8); diff --git a/tasks/transform_conformance/tests/babel-plugin-transform-logical-assignment-operators/test/fixtures/computed-props/output.js b/tasks/transform_conformance/tests/babel-plugin-transform-logical-assignment-operators/test/fixtures/computed-props/output.js new file mode 100644 index 00000000000000..e0666979bb08c3 --- /dev/null +++ b/tasks/transform_conformance/tests/babel-plugin-transform-logical-assignment-operators/test/fixtures/computed-props/output.js @@ -0,0 +1,15 @@ +var _unboundProp, _unboundObj, _unboundObj2, _unboundProp2, _boundObj$prop, _boundObj$prop2, _unboundProp3, _unboundProp4; + +let boundObj, boundProp; + +boundObj[boundProp] && (boundObj[boundProp] = 1); +boundObj[_unboundProp = unboundProp] && (boundObj[_unboundProp] = 2); + +(_unboundObj = unboundObj)[boundProp] && (_unboundObj[boundProp] = 3); +(_unboundObj2 = unboundObj)[_unboundProp2 = unboundProp] && (_unboundObj2[_unboundProp2] = 4); + +(_boundObj$prop = boundObj.prop)[boundProp] && (_boundObj$prop[boundProp] = 5); +(_boundObj$prop2 = boundObj.prop)[_unboundProp3 = unboundProp] && (_boundObj$prop2[_unboundProp3] = 6); + +this[boundProp] && (this[boundProp] = 7); +this[_unboundProp4 = unboundProp] && (this[_unboundProp4] = 8); diff --git a/tasks/transform_conformance/tests/babel-plugin-transform-logical-assignment-operators/test/fixtures/options.json b/tasks/transform_conformance/tests/babel-plugin-transform-logical-assignment-operators/test/fixtures/options.json new file mode 100644 index 00000000000000..754c7c95050eb6 --- /dev/null +++ b/tasks/transform_conformance/tests/babel-plugin-transform-logical-assignment-operators/test/fixtures/options.json @@ -0,0 +1,5 @@ +{ + "plugins": [ + "transform-logical-assignment-operators" + ] +}