1
0
mirror of https://github.com/robertkrimen/otto synced 2025-10-26 20:28:49 +08:00

Fix trying to call a non-function as a function

This commit is contained in:
Robert Krimen
2012-10-22 14:29:14 -07:00
parent 820c21423f
commit c1a21812fe
3 changed files with 22 additions and 0 deletions

View File

@@ -1605,6 +1605,19 @@ func TestNewFunction(t *testing.T) {
test(`
new Function("a", "b", "c", "return b + 2")(10, 11, 12)
`, "13")
test(`raise:
new 1
`, "TypeError: 1 is not a function")
// TODO Report something sane.
test(`raise:
new this
`, "TypeError: is not a function")
test(`raise:
new {}
`, "TypeError: [object Object] is not a function")
}
func TestNewPrototype(t *testing.T) {