mirror of
https://github.com/leporello-js/leporello-js
synced 2026-01-13 13:04:30 -08:00
fix
This commit is contained in:
48
test/test.js
48
test/test.js
@@ -2724,15 +2724,10 @@ const y = x()`
|
||||
const i = await test_initial_state_async(`
|
||||
const x = () => 1
|
||||
const delay = async time => {
|
||||
await 1 //TODO Promise.resolve()
|
||||
await 1
|
||||
x()
|
||||
}
|
||||
await delay(3)
|
||||
/* TODO
|
||||
await Promise.all([
|
||||
delay(3),
|
||||
])
|
||||
*/
|
||||
`)
|
||||
const root = root_calltree_node(i)
|
||||
assert_equal(root.children.length, 1)
|
||||
@@ -2741,34 +2736,6 @@ const y = x()`
|
||||
assert_equal(call_delay.fn.name, 'delay')
|
||||
}),
|
||||
|
||||
// TODO
|
||||
test('async/await logs out of order', async () => {
|
||||
const i = await test_initial_state_async(`
|
||||
const delay = async time => {
|
||||
await new Promise(res => globalThis.setTimeout(res, time*10))
|
||||
console.log(time)
|
||||
}
|
||||
|
||||
await Promise.all([delay(2), delay(1)])
|
||||
`)
|
||||
const logs = i.logs.logs.map(l => l.args[0])
|
||||
assert_equal(logs, [1, 2])
|
||||
}),
|
||||
|
||||
|
||||
/* TODO
|
||||
test('p', async () => {
|
||||
const i = await assert_code_evals_to_async(`
|
||||
const res = Promise.resolve(1)
|
||||
Object.assign(res, {mark: 'resolved'})
|
||||
await Object.assign(new Promise(resolve => resolve()), {mark: 'w'})
|
||||
`,
|
||||
1
|
||||
)
|
||||
|
||||
}),
|
||||
*/
|
||||
|
||||
test('async/await logs out of order', async () => {
|
||||
const i = await test_initial_state_async(`
|
||||
// Init promises p1 and p2 that are resolved in different order (p2 then
|
||||
@@ -2787,4 +2754,17 @@ const y = x()`
|
||||
assert_equal(logs, [2, 1])
|
||||
}),
|
||||
|
||||
test('async/await logs out of order', async () => {
|
||||
const i = await test_initial_state_async(`
|
||||
const delay = async time => {
|
||||
await new Promise(res => globalThis.setTimeout(res, time*10))
|
||||
console.log(time)
|
||||
}
|
||||
|
||||
await Promise.all([delay(2), delay(1)])
|
||||
`)
|
||||
const logs = i.logs.logs.map(l => l.args[0])
|
||||
assert_equal(logs, [1, 2])
|
||||
}),
|
||||
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user