mirror of
https://github.com/swc-project/swc.git
synced 2024-12-23 21:54:36 +03:00
test(es): Add auto-closable tests (#3995)
This commit is contained in:
parent
499d204ae3
commit
dabc4920a8
@ -204,5 +204,9 @@ fn stdout_of(code: &str) -> Result<String, Error> {
|
||||
)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
9
crates/swc/tests/exec/.issue-2624/exec.js
Normal file
9
crates/swc/tests/exec/.issue-2624/exec.js
Normal file
@ -0,0 +1,9 @@
|
||||
async function runCounters() {
|
||||
for (const idebug of [1, 2, 3]) {
|
||||
setTimeout(() => console.log(`idebug = ${idebug}`), 100);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
runCounters()
|
||||
runCounters()
|
8
crates/swc/tests/exec/.issue-2834/exec.js
Normal file
8
crates/swc/tests/exec/.issue-2834/exec.js
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
var b;
|
||||
var d;
|
||||
var p;
|
||||
|
||||
[(b)] = [3]; // correct
|
||||
({ p: (d) } = {}); // correct
|
||||
[(parseInt.prop)] = [3]; // correct
|
6
crates/swc/tests/exec/.issue-2865/exec.js
Normal file
6
crates/swc/tests/exec/.issue-2865/exec.js
Normal file
@ -0,0 +1,6 @@
|
||||
Object.prototype.getTypeof = function () {
|
||||
return typeof this;
|
||||
}
|
||||
|
||||
console.log(Symbol().getTypeof())
|
||||
console.log(typeof Symbol())
|
1
crates/swc/tests/exec/.issue-2948/exec.js
Normal file
1
crates/swc/tests/exec/.issue-2948/exec.js
Normal file
@ -0,0 +1 @@
|
||||
"\u{Dc00}" // Invalid unicode code point
|
6
crates/swc/tests/exec/.issue-3006/exec.js
Normal file
6
crates/swc/tests/exec/.issue-3006/exec.js
Normal file
@ -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()
|
39
crates/swc/tests/exec/.issue-3660/exec.ts
Normal file
39
crates/swc/tests/exec/.issue-3660/exec.ts
Normal file
@ -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<number>(),
|
||||
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<number>()
|
||||
}) {
|
||||
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({})
|
6
crates/swc/tests/exec/.issue-3700/exec.js
Normal file
6
crates/swc/tests/exec/.issue-3700/exec.js
Normal file
@ -0,0 +1,6 @@
|
||||
class A {
|
||||
#a = 123n
|
||||
foo() {
|
||||
this.#a++
|
||||
}
|
||||
}
|
28
crates/swc/tests/exec/.issue-3965/.swcrc
Normal file
28
crates/swc/tests/exec/.issue-3965/.swcrc
Normal file
@ -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
|
||||
}
|
||||
}
|
11
crates/swc/tests/exec/.issue-3965/exec.js
Normal file
11
crates/swc/tests/exec/.issue-3965/exec.js
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user