test(es): Add auto-closable tests (#3995)

This commit is contained in:
Donny/강동윤 2022-03-13 17:45:55 +09:00 committed by GitHub
parent 499d204ae3
commit dabc4920a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 119 additions and 1 deletions

View File

@ -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)
}

View File

@ -0,0 +1,9 @@
async function runCounters() {
for (const idebug of [1, 2, 3]) {
setTimeout(() => console.log(`idebug = ${idebug}`), 100);
}
}
runCounters()
runCounters()

View File

@ -0,0 +1,8 @@
var b;
var d;
var p;
[(b)] = [3]; // correct
({ p: (d) } = {}); // correct
[(parseInt.prop)] = [3]; // correct

View File

@ -0,0 +1,6 @@
Object.prototype.getTypeof = function () {
return typeof this;
}
console.log(Symbol().getTypeof())
console.log(typeof Symbol())

View File

@ -0,0 +1 @@
"\u{Dc00}" // Invalid unicode code point

View 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()

View 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({})

View File

@ -0,0 +1,6 @@
class A {
#a = 123n
foo() {
this.#a++
}
}

View 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
}
}

View 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