From 0d93b049622c215508dedbd413f9f2db9c9d367c Mon Sep 17 00:00:00 2001 From: magic-akari Date: Wed, 14 Jun 2023 20:16:44 +0800 Subject: [PATCH] chore: add test cases --- .../tests/fixture/namespace/1/input.ts | 23 +++++++++++++ .../tests/fixture/namespace/1/output.js | 32 +++++++++++++++++++ .../tests/fixture/namespace/2/input.ts | 17 ++++++++++ .../tests/fixture/namespace/2/output.js | 17 ++++++++++ 4 files changed, 89 insertions(+) create mode 100644 crates/swc_ecma_transforms_typescript/tests/fixture/namespace/1/input.ts create mode 100644 crates/swc_ecma_transforms_typescript/tests/fixture/namespace/1/output.js create mode 100644 crates/swc_ecma_transforms_typescript/tests/fixture/namespace/2/input.ts create mode 100644 crates/swc_ecma_transforms_typescript/tests/fixture/namespace/2/output.js diff --git a/crates/swc_ecma_transforms_typescript/tests/fixture/namespace/1/input.ts b/crates/swc_ecma_transforms_typescript/tests/fixture/namespace/1/input.ts new file mode 100644 index 0000000000000..2a46ff99c21ed --- /dev/null +++ b/crates/swc_ecma_transforms_typescript/tests/fixture/namespace/1/input.ts @@ -0,0 +1,23 @@ +namespace X1 { + console.log(1); +} + +export namespace X2 { + console.log(2); +} + +namespace X3 { + namespace X4 { + console.log(4); + } +} + +namespace X5 { + export namespace X6 { + console.log(6); + } +} + +namespace X7.X8 { + console.log(8); +} diff --git a/crates/swc_ecma_transforms_typescript/tests/fixture/namespace/1/output.js b/crates/swc_ecma_transforms_typescript/tests/fixture/namespace/1/output.js new file mode 100644 index 0000000000000..cc86fcb2015c9 --- /dev/null +++ b/crates/swc_ecma_transforms_typescript/tests/fixture/namespace/1/output.js @@ -0,0 +1,32 @@ +var X1; +(function (X1) { + console.log(1); +})(X1 || (X1 = {})); + +export var X2; +(function (X2) { + console.log(2); +})(X2 || (X2 = {})); + +var X3; +(function (X3) { + let X4; + (function (X4) { + console.log(4); + })(X4 || (X4 = {})); +})(X3 || (X3 = {})); + +var X5; +(function (X5) { + let X6; + (function (X6) { + console.log(6); + })(X6 = X5.X6 || (X5.X6 = {})); +})(X5 || (X5 = {})); + +var X7; +(function (X7) { + (function (X8) { + console.log(8); + })(X8 = X7.X8 || (X7.X8 = {})); +})(X7 || (X7 = {})); \ No newline at end of file diff --git a/crates/swc_ecma_transforms_typescript/tests/fixture/namespace/2/input.ts b/crates/swc_ecma_transforms_typescript/tests/fixture/namespace/2/input.ts new file mode 100644 index 0000000000000..240d59b176f46 --- /dev/null +++ b/crates/swc_ecma_transforms_typescript/tests/fixture/namespace/2/input.ts @@ -0,0 +1,17 @@ +class X1 {} + +namespace X1 { + console.log(1); +} + +function X2() {} + +namespace X2 { + console.log(2); +} + +enum X3 {} + +namespace X3 { + console.log(3); +} diff --git a/crates/swc_ecma_transforms_typescript/tests/fixture/namespace/2/output.js b/crates/swc_ecma_transforms_typescript/tests/fixture/namespace/2/output.js new file mode 100644 index 0000000000000..04ed1dc7e3435 --- /dev/null +++ b/crates/swc_ecma_transforms_typescript/tests/fixture/namespace/2/output.js @@ -0,0 +1,17 @@ +class X1 { +} +(function (X1) { + console.log(1); +})(X1 || (X1 = {})); + +function X2() { } +(function (X2) { + console.log(2); +})(X2 || (X2 = {})); + +var X3; +(function (X3) { +})(X3 || (X3 = {})); +(function (X3) { + console.log(3); +})(X3 || (X3 = {}));