mirror of
https://github.com/leporello-js/leporello-js
synced 2026-01-13 21:14:28 -08:00
fix
This commit is contained in:
@@ -21,8 +21,8 @@ const isError = object =>
|
|||||||
object instanceof globalThis.run_window.Error
|
object instanceof globalThis.run_window.Error
|
||||||
|
|
||||||
const isPromise = object =>
|
const isPromise = object =>
|
||||||
object instanceof Promise
|
object instanceof Promise
|
||||||
||
|
||
|
||||||
object instanceof globalThis.run_window.Promise
|
object instanceof globalThis.run_window.Promise
|
||||||
|
|
||||||
const displayed_entries = object => {
|
const displayed_entries = object => {
|
||||||
@@ -49,7 +49,15 @@ export const stringify_for_header = v => {
|
|||||||
// TODO clickable link, 'fn', cursive
|
// TODO clickable link, 'fn', cursive
|
||||||
return 'fn ' + v.name
|
return 'fn ' + v.name
|
||||||
} else if (isPromise(v)) {
|
} else if (isPromise(v)) {
|
||||||
return 'Promise<>'
|
if(v.status == null) {
|
||||||
|
return `Promise<pending>`
|
||||||
|
} else {
|
||||||
|
if(status.ok) {
|
||||||
|
return `Promise<fulfilled: ${stringify_for_header(status.value)}>`
|
||||||
|
} else {
|
||||||
|
return `Promise<fulfilled: ${stringify_for_header(status.error)}>`
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if(isError(v)) {
|
} else if(isError(v)) {
|
||||||
return v.toString()
|
return v.toString()
|
||||||
} else if(type == 'object') {
|
} else if(type == 'object') {
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ export const patch_promise = window => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
class PromiseWithStatus extends Promise {
|
class PromiseWithStatus extends window.Promise {
|
||||||
constructor(fn) {
|
constructor(fn) {
|
||||||
let status
|
let status
|
||||||
let is_constructor_finished = false
|
let is_constructor_finished = false
|
||||||
const p = new Promise.Original(
|
const p = new window.Promise.Original(
|
||||||
(resolve, reject) => {
|
(resolve, reject) => {
|
||||||
fn(
|
fn(
|
||||||
(value) => {
|
(value) => {
|
||||||
@@ -47,7 +47,7 @@ export const patch_promise = window => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PromiseWithStatus.Original = Promise
|
PromiseWithStatus.Original = window.Promise
|
||||||
|
|
||||||
window.Promise = PromiseWithStatus
|
window.Promise = PromiseWithStatus
|
||||||
}
|
}
|
||||||
|
|||||||
12
test/test.js
12
test/test.js
@@ -2767,4 +2767,16 @@ const y = x()`
|
|||||||
assert_equal(logs, [1, 2])
|
assert_equal(logs, [1, 2])
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
test('async/await bug', async () => {
|
||||||
|
const code = `
|
||||||
|
const f = async () => {
|
||||||
|
console.log('f')
|
||||||
|
}
|
||||||
|
|
||||||
|
await f()
|
||||||
|
`
|
||||||
|
const i = await test_initial_state_async(code)
|
||||||
|
const cursor = COMMANDS.move_cursor(i, code.indexOf('console'))
|
||||||
|
}),
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user