Support async do expressions proposal (#10813)
* Support async-do-expression proposal * Add more tests * Add changelog
This commit is contained in:
1 parent
68b158b811
commit
edc7a30f26
9 files changed
+167
-1
No files matched your search
@@ -0,0 +1,87 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`async-do-expressions.js [espree] format 1`] = `
|
||||
"Unexpected token do (1:7)
|
||||
> 1 | async do {
|
||||
| ^
|
||||
2 | 1;
|
||||
3 | };
|
||||
4 |"
|
||||
`;
|
||||
|
||||
exports[`async-do-expressions.js [meriyah] format 1`] = `
|
||||
"[1:8]: Unexpected token: 'do' (1:8)
|
||||
> 1 | async do {
|
||||
| ^
|
||||
2 | 1;
|
||||
3 | };
|
||||
4 |"
|
||||
`;
|
||||
|
||||
exports[`async-do-expressions.js format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["babel"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
async do {
|
||||
1;
|
||||
};
|
||||
|
||||
(async do {});
|
||||
|
||||
let x = async do {
|
||||
if (foo()) { f() }
|
||||
else if (bar()) { g() }
|
||||
else { h() }
|
||||
};
|
||||
|
||||
async do {
|
||||
await 42
|
||||
}
|
||||
|
||||
function iter() {
|
||||
return async do {
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
let x = async do {
|
||||
let tmp = f();
|
||||
tmp * tmp + 1
|
||||
};
|
||||
|
||||
=====================================output=====================================
|
||||
(async do {
|
||||
1;
|
||||
});
|
||||
|
||||
(async do {});
|
||||
|
||||
let x = async do {
|
||||
if (foo()) {
|
||||
f();
|
||||
} else if (bar()) {
|
||||
g();
|
||||
} else {
|
||||
h();
|
||||
}
|
||||
};
|
||||
|
||||
(async do {
|
||||
await 42;
|
||||
});
|
||||
|
||||
function iter() {
|
||||
return async do {
|
||||
return 1;
|
||||
};
|
||||
}
|
||||
|
||||
let x = async do {
|
||||
let tmp = f();
|
||||
tmp * tmp + 1;
|
||||
};
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
@@ -0,0 +1,26 @@
|
||||
async do {
|
||||
1;
|
||||
};
|
||||
|
||||
(async do {});
|
||||
|
||||
let x = async do {
|
||||
if (foo()) { f() }
|
||||
else if (bar()) { g() }
|
||||
else { h() }
|
||||
};
|
||||
|
||||
async do {
|
||||
await 42
|
||||
}
|
||||
|
||||
function iter() {
|
||||
return async do {
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
let x = async do {
|
||||
let tmp = f();
|
||||
tmp * tmp + 1
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
run_spec(__dirname, ["babel"], { errors: { espree: true, meriyah: true } });
|
||||
@@ -1,5 +1,35 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`async-do-expressions.js [espree] format 1`] = `
|
||||
"Unexpected token do (1:7)
|
||||
> 1 | async do { await requestAPI().json() };
|
||||
| ^
|
||||
2 |"
|
||||
`;
|
||||
|
||||
exports[`async-do-expressions.js [meriyah] format 1`] = `
|
||||
"[1:8]: Unexpected token: 'do' (1:8)
|
||||
> 1 | async do { await requestAPI().json() };
|
||||
| ^
|
||||
2 |"
|
||||
`;
|
||||
|
||||
exports[`async-do-expressions.js format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["babel", "babel-ts", "babel-flow"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
async do { await requestAPI().json() };
|
||||
|
||||
=====================================output=====================================
|
||||
(async do {
|
||||
await requestAPI().json();
|
||||
});
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`async-generators.js format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["babel", "babel-ts", "babel-flow"]
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
async do { await requestAPI().json() };
|
||||
@@ -28,6 +28,7 @@ run_spec(__dirname, ["babel", "babel-ts", "babel-flow"], {
|
||||
"module-string-names.js",
|
||||
"class-static-block.js",
|
||||
"module-blocks.js",
|
||||
"async-do-expressions.js",
|
||||
],
|
||||
meriyah: [
|
||||
"decimal.js",
|
||||
@@ -52,6 +53,7 @@ run_spec(__dirname, ["babel", "babel-ts", "babel-flow"], {
|
||||
"import-assertions-static.js",
|
||||
"module-string-names.js",
|
||||
"module-blocks.js",
|
||||
"async-do-expressions.js",
|
||||
],
|
||||
},
|
||||
});
|
||||
Reference in new issue
Block a user