MCPcopy Index your code
hub / github.com/Shopify/go-lua / TestLocIsCorrectOnFuncCall

Function TestLocIsCorrectOnFuncCall

vm_test.go:423–442  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

421}
422
423func TestLocIsCorrectOnFuncCall(t *testing.T) {
424 l := NewState()
425 if err := l.Load(strings.NewReader(`
426 function barf()
427 a = 3 + 2
428 isNotDefined("Boom!", a) -- line 4; is the source of the error
429 end
430 barf() -- line 6
431 `), "test", ""); err != nil {
432 t.Errorf("Unexpected error! Got %v", err)
433 }
434 err := l.ProtectedCall(0, 0, 0)
435 if err == nil {
436 t.Errorf("Expected error! Got none... :(")
437 } else {
438 if err.Error() != "runtime error: [string \"test\"]:4: attempt to call a nil value" {
439 t.Errorf("Wrong error reported: %v", err)
440 }
441 }
442}
443
444func TestLocIsCorrectOnError(t *testing.T) {
445 l := NewState()

Callers

nothing calls this directly

Calls 4

LoadMethod · 0.95
ProtectedCallMethod · 0.95
NewStateFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected