fix expand calltree node for new calls

This commit is contained in:
Dmitry Vasilev
2023-01-08 06:19:38 +08:00
parent a0b3553727
commit 2ee6290452
2 changed files with 21 additions and 1 deletions

View File

@@ -338,7 +338,11 @@ export const eval_modules = (
is_recording_deferred_calls = false
children = null
try {
node.fn.apply(node.context, node.args)
if(node.is_new) {
new node.fn(...node.args)
} else {
node.fn.apply(node.context, node.args)
}
} catch(e) {
// do nothing. Exception was caught and recorded inside 'trace'
}

View File

@@ -1639,6 +1639,22 @@ const y = x()`
assert_equal(first2.code, first2.children[0].code)
}),
test('expand_calltree_node new', () => {
const code = `
const make_class = new Function("return class { constructor(x) { x() } }")
const clazz = make_class()
const x = () => 1
new clazz(x)
`
const s = test_initial_state(code)
const new_call = root_calltree_node(s).children.at(-1)
const expanded_new_call = COMMANDS.calltree.click(s, new_call.id).state
const x_call = root_calltree_node(expanded_new_call)
.children.at(-1)
.children[0]
assert_equal(x_call.fn.name, 'x')
}),
test('expand_calltree_node native', () => {
const s = test_initial_state(`[1,2,3].map(x => x + 1)`)
const map = root_calltree_node(s).children[0]