fix is not a function errors

This commit is contained in:
Dmitry Vasilev
2023-01-18 19:21:25 +08:00
parent 3047e89e8a
commit 096ca5e495
2 changed files with 76 additions and 61 deletions

View File

@@ -462,22 +462,20 @@ export const tests = [
)
}),
test('undefined is not a function', () => {
const code =
test('error is not a function', () => {
assert_code_error(
`
const x = () => null();
const unreachable = () => 1
x();
const x = null
x()
`,
'TypeError: x is not a function'
)
assert_code_error(
`
const s1 = test_initial_state(code)
// TODO fix error messages
const message = root_calltree_node(s1).error.message
assert_equal(
message == "Cannot read property 'apply' of null"
||
message == "Cannot read properties of null (reading 'apply')"
,
true
const foo = () => ([{bar: {}}])
foo()[0].bar.baz()
`,
'TypeError: foo(...)[0].bar.baz is not a function'
)
}),