Skip to content

Commit

Permalink
Add babel-only await tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sosukesuzuki committed Feb 25, 2021
1 parent 2e59c34 commit 5d5eaea
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 0 deletions.
70 changes: 70 additions & 0 deletions tests/js/await-with-parens/__snapshots__/jsfmt.spec.js.snap
@@ -0,0 +1,70 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`await-with-parens.js [espree] format 1`] = `
"Cannot use keyword 'await' outside an async function (1:25)
> 1 | function foo(promise) { await (promise); }
| ^
2 |
3 | function a() {
4 | return await (1)"
`;
exports[`await-with-parens.js [meriyah] format 1`] = `
"[1:29]: 'Await' may not be used as an identifier in this context (1:29)
> 1 | function foo(promise) { await (promise); }
| ^
2 |
3 | function a() {
4 | return await (1)"
`;
exports[`await-with-parens.js format 1`] = `
====================================options=====================================
parsers: ["babel"]
printWidth: 80
| printWidth
=====================================input======================================
function foo(promise) { await (promise); }
function a() {
return await (1)
}
() => { await (x) };
function foo() {
await
(foo);
}
export class C {
p = await (0);
}
await (0);
=====================================output=====================================
function foo(promise) {
await(promise);
}
function a() {
return await(1);
}
() => {
await(x);
};
function foo() {
await(foo);
}
export class C {
p = await 0;
}
await 0;
================================================================================
`;
18 changes: 18 additions & 0 deletions tests/js/await-with-parens/await-with-parens.js
@@ -0,0 +1,18 @@
function foo(promise) { await (promise); }

function a() {
return await (1)
}

() => { await (x) };

function foo() {
await
(foo);
}

export class C {
p = await (0);
}

await (0);
6 changes: 6 additions & 0 deletions tests/js/await-with-parens/jsfmt.spec.js
@@ -0,0 +1,6 @@
run_spec(__dirname, ["babel"], {
errors: {
espree: true,
meriyah: true,
},
});

0 comments on commit 5d5eaea

Please sign in to comment.