(t *testing.T)
| 300 | } |
| 301 | |
| 302 | func TestError(t *testing.T) { |
| 303 | l := NewState() |
| 304 | BaseOpen(l) |
| 305 | errorHandled := false |
| 306 | program := "error('error')" |
| 307 | l.PushGoFunction(func(l *State) int { |
| 308 | if l.Top() == 0 { |
| 309 | t.Error("error handler received no arguments") |
| 310 | } else if errorMessage, ok := l.ToString(-1); !ok { |
| 311 | t.Errorf("error handler received %s instead of string", TypeNameOf(l, -1)) |
| 312 | } else if errorMessage != chunkID(program)+":1: error" { |
| 313 | t.Errorf("error handler received '%s' instead of 'error'", errorMessage) |
| 314 | } |
| 315 | errorHandled = true |
| 316 | return 1 |
| 317 | }) |
| 318 | LoadString(l, program) |
| 319 | l.ProtectedCall(0, 0, -2) |
| 320 | if !errorHandled { |
| 321 | t.Error("error not handled") |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | func TestErrorf(t *testing.T) { |
| 326 | l := NewState() |
nothing calls this directly
no test coverage detected