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

Function TestTableNext

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

Source from the content-addressed store, hash-verified

276}
277
278func TestTableNext(t *testing.T) {
279 l := NewState()
280 OpenLibraries(l)
281 l.CreateTable(10, 0)
282 for i := 1; i <= 4; i++ {
283 l.PushInteger(i)
284 l.PushValue(-1)
285 l.SetTable(-3)
286 }
287 if length := LengthEx(l, -1); length != 4 {
288 t.Errorf("expected table length to be 4, but was %d", length)
289 }
290 count := 0
291 for l.PushNil(); l.Next(-2); count++ {
292 if k, v := CheckInteger(l, -2), CheckInteger(l, -1); k != v {
293 t.Errorf("key %d != value %d", k, v)
294 }
295 l.Pop(1)
296 }
297 if count != 4 {
298 t.Errorf("incorrect iteration count %d in Next()", count)
299 }
300}
301
302func TestError(t *testing.T) {
303 l := NewState()

Callers

nothing calls this directly

Calls 11

CreateTableMethod · 0.95
PushIntegerMethod · 0.95
PushValueMethod · 0.95
SetTableMethod · 0.95
PushNilMethod · 0.95
NextMethod · 0.95
PopMethod · 0.95
NewStateFunction · 0.85
OpenLibrariesFunction · 0.85
LengthExFunction · 0.85
CheckIntegerFunction · 0.85

Tested by

no test coverage detected