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

Function TestLocIsCorrectOnRegisteredFuncCall

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

Source from the content-addressed store, hash-verified

399}
400
401func TestLocIsCorrectOnRegisteredFuncCall(t *testing.T) {
402 l := NewState()
403 l.Register("barf", func(l *State) int {
404 Errorf(l, "Boom!")
405 return 0
406 })
407 if err := l.Load(strings.NewReader(`
408 local thing = barf() -- line 2; is the source of the error
409 print(thing) -- line 3; this won't execute, and must NOT be the loc of the error!
410 `), "test", ""); err != nil {
411 t.Errorf("Unexpected error! Got %v", err)
412 }
413 err := l.ProtectedCall(0, 0, 0)
414 if err == nil {
415 t.Errorf("Expected error! Got none... :(")
416 } else {
417 if err.Error() != "runtime error: [string \"test\"]:2: Boom!" {
418 t.Errorf("Wrong error reported: %v", err)
419 }
420 }
421}
422
423func TestLocIsCorrectOnFuncCall(t *testing.T) {
424 l := NewState()

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected