2019-01-11 13:27:28 +03:00
|
|
|
package runtime_test
|
2019-01-09 10:17:42 +03:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestError(t *testing.T) {
|
2019-01-16 23:23:20 +03:00
|
|
|
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")
|
|
|
|
|
2019-02-21 03:26:11 +03:00
|
|
|
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")
|
2019-01-09 10:17:42 +03:00
|
|
|
}
|