diff --git a/crates/swc/tests/exec.rs b/crates/swc/tests/exec.rs index 5c051dccd36..f9d06b8c7d5 100644 --- a/crates/swc/tests/exec.rs +++ b/crates/swc/tests/exec.rs @@ -204,5 +204,9 @@ fn stdout_of(code: &str) -> Result { ) } - Ok(String::from_utf8_lossy(&actual_output.stdout).to_string()) + let s = String::from_utf8_lossy(&actual_output.stdout).to_string(); + if s.trim().is_empty() { + bail!("empty stdout"); + } + Ok(s) } diff --git a/crates/swc/tests/exec/.issue-2624/exec.js b/crates/swc/tests/exec/.issue-2624/exec.js new file mode 100644 index 00000000000..c4bc23f69a6 --- /dev/null +++ b/crates/swc/tests/exec/.issue-2624/exec.js @@ -0,0 +1,9 @@ +async function runCounters() { + for (const idebug of [1, 2, 3]) { + setTimeout(() => console.log(`idebug = ${idebug}`), 100); + } +} + + +runCounters() +runCounters() \ No newline at end of file diff --git a/crates/swc/tests/exec/.issue-2834/exec.js b/crates/swc/tests/exec/.issue-2834/exec.js new file mode 100644 index 00000000000..732dff968f1 --- /dev/null +++ b/crates/swc/tests/exec/.issue-2834/exec.js @@ -0,0 +1,8 @@ + +var b; +var d; +var p; + +[(b)] = [3]; // correct +({ p: (d) } = {}); // correct +[(parseInt.prop)] = [3]; // correct \ No newline at end of file diff --git a/crates/swc/tests/exec/.issue-2865/exec.js b/crates/swc/tests/exec/.issue-2865/exec.js new file mode 100644 index 00000000000..acf0ee08974 --- /dev/null +++ b/crates/swc/tests/exec/.issue-2865/exec.js @@ -0,0 +1,6 @@ +Object.prototype.getTypeof = function () { + return typeof this; +} + +console.log(Symbol().getTypeof()) +console.log(typeof Symbol()) \ No newline at end of file diff --git a/crates/swc/tests/exec/.issue-2948/exec.js b/crates/swc/tests/exec/.issue-2948/exec.js new file mode 100644 index 00000000000..969000ac7a7 --- /dev/null +++ b/crates/swc/tests/exec/.issue-2948/exec.js @@ -0,0 +1 @@ +"\u{Dc00}" // Invalid unicode code point \ No newline at end of file diff --git a/crates/swc/tests/exec/.issue-3006/exec.js b/crates/swc/tests/exec/.issue-3006/exec.js new file mode 100644 index 00000000000..9fe1184e7e6 --- /dev/null +++ b/crates/swc/tests/exec/.issue-3006/exec.js @@ -0,0 +1,6 @@ +async function a() { + for (const number_in_a_sequence of Array.from(new Array(7), (_, i) => i)) { + setTimeout(() => console.log(number_in_a_sequence), 10) + } +} +a() \ No newline at end of file diff --git a/crates/swc/tests/exec/.issue-3660/exec.ts b/crates/swc/tests/exec/.issue-3660/exec.ts new file mode 100644 index 00000000000..303703d0e2c --- /dev/null +++ b/crates/swc/tests/exec/.issue-3660/exec.ts @@ -0,0 +1,39 @@ +// Adding a type to Set breaks the + +const { Test } = require("mocha"); + +// variable on the next line +function Test1({ + var1 = new Set(), + var2 = "123", // <- this variable is renamed to `var21` + var3 = "456" +}) { + console.log(var1, var2, var3); // <- here `var2` is used +} + +// Placing the Set on the last line works +function Test2({ + var2 = "123", + var3 = "456", + var1 = new Set() +}) { + console.log(var1, var2, var3); +} + +// Removing the type from Set also works +function Test3({ + var1 = new Set(), + var2 = "123", + var3 = "456" +}) { + console.log(var1, var2, var3); +} + +Test1({}) +Test1({}) + +Test2({}) +Test2({}) + +Test3({}) +Test3({}) \ No newline at end of file diff --git a/crates/swc/tests/exec/.issue-3700/exec.js b/crates/swc/tests/exec/.issue-3700/exec.js new file mode 100644 index 00000000000..c0732885ca3 --- /dev/null +++ b/crates/swc/tests/exec/.issue-3700/exec.js @@ -0,0 +1,6 @@ +class A { + #a = 123n + foo() { + this.#a++ + } +} \ No newline at end of file diff --git a/crates/swc/tests/exec/.issue-3965/.swcrc b/crates/swc/tests/exec/.issue-3965/.swcrc new file mode 100644 index 00000000000..d2793f0edaf --- /dev/null +++ b/crates/swc/tests/exec/.issue-3965/.swcrc @@ -0,0 +1,28 @@ +{ + "jsc": { + "parser": { + "syntax": "ecmascript", + "jsx": false, + "dynamicImport": false, + "privateMethod": false, + "functionBind": false, + "exportDefaultFrom": false, + "exportNamespaceFrom": false, + "decorators": false, + "decoratorsBeforeExport": false, + "topLevelAwait": false, + "importMeta": false + }, + "transform": null, + "target": "es5", + "loose": false, + "externalHelpers": false + }, + "module": { + "type": "commonjs", + "strict": false, + "strictMode": false, + "lazy": false, + "noInterop": false + } +} \ No newline at end of file diff --git a/crates/swc/tests/exec/.issue-3965/exec.js b/crates/swc/tests/exec/.issue-3965/exec.js new file mode 100644 index 00000000000..3162a5c6676 --- /dev/null +++ b/crates/swc/tests/exec/.issue-3965/exec.js @@ -0,0 +1,11 @@ +const store = { + address: '101 Main Street', + what: function () { + return this.address + }, + arrow: () => { + return this.address + } +} +console.log(store.what()) // '101 Main Street' +console.log(store.arrow()) // undefined \ No newline at end of file