xgo/runtime/vm_call_test.go
earncef 6dd573c3f6 Runtime error trace format (#111)
* Runtime error format

* Parser and Compiler error formats updated
2019-02-22 13:39:07 -08:00

19 lines
466 B
Go

package runtime_test
import "testing"
func TestCall(t *testing.T) {
expect(t, `a := { b: func(x) { return x + 2 } }; out = a.b(5)`, 7)
expect(t, `a := { b: { c: func(x) { return x + 2 } } }; out = a.b.c(5)`, 7)
expect(t, `a := { b: { c: func(x) { return x + 2 } } }; out = a["b"].c(5)`, 7)
expectError(t, `a := 1
b := func(a, c) {
c(a)
}
c := func(a) {
a()
}
b(a, c)
`, "Runtime Error: not callable: int\n\tat test:7:4\n\tat test:3:4\n\tat test:9:1")
}