3500c686b3
- add type infos to VM error messages - add 'Name' to UserFunction objects - add 'expectErrorString' to VM tests - replace vm.expectError() with vm.expectErrorString() to make it more explicit - add source map info to VM error messages - optimization in function calls - add file/line/col info to compiler errors - change stdlib module to be loaded from VM (instead of compiler) so they can be properly loaded after the source is compiled into binary - VM can take builtin modules optionally
21 lines
823 B
Go
21 lines
823 B
Go
package runtime_test
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestError(t *testing.T) {
|
|
expect(t, `out = error(1)`, errorObject(1))
|
|
expect(t, `out = error(1).value`, 1)
|
|
expect(t, `out = error("some error")`, errorObject("some error"))
|
|
expect(t, `out = error("some" + " error")`, errorObject("some error"))
|
|
expect(t, `out = func() { return error(5) }()`, errorObject(5))
|
|
expect(t, `out = error(error("foo"))`, errorObject(errorObject("foo")))
|
|
expect(t, `out = error("some error")`, errorObject("some error"))
|
|
expect(t, `out = error("some error").value`, "some error")
|
|
expect(t, `out = error("some error")["value"]`, "some error")
|
|
|
|
expectError(t, `error("error").err`, "invalid index on error")
|
|
expectError(t, `error("error").value_`, "invalid index on error")
|
|
expectError(t, `error([1,2,3])[1]`, "invalid index on error")
|
|
}
|