This commit is contained in:
Dmitry Vasilev
2022-12-22 22:14:36 +08:00
parent 23429845d2
commit 4dbc7c26e2
6 changed files with 102 additions and 46 deletions

View File

@@ -2779,18 +2779,38 @@ const y = x()`
)
}),
// TODO
/*
test('async/await Promise.then creates subcall', async () => {
const i = await test_initial_state_async(`
await Promise.resolve(1).then(x => {
})
const x = () => 1
await Promise.resolve(1).then(x)
`)
console.log('i', root_calltree_node(i))
const root = root_calltree_node(i)
assert_equal(root.children.at(-1).children[0].fn.name, 'x')
}),
test('async/await bug', async () => {
test('async/await Promise.catch creates subcall', async () => {
const i = await test_initial_state_async(`
const x = () => 1
await Promise.reject(1).catch(x)
`)
const root = root_calltree_node(i)
assert_equal(root.children.at(-1).children[0].fn.name, 'x')
}),
test_only('async/await native Promise.then creates subcall', async () => {
const i = await test_initial_state_async(`
const x = () => 1
const async_fn = async () => 1
await async_fn().then(x)
`)
const root = root_calltree_node(i)
assert_equal(root.children.at(-1).children[0].fn.name, 'x')
}),
/*
// TODO
test('async/await move_cursor', async () => {
const code = `
const f = async () => {
console.log('f')