MCPcopy Index your code
hub / github.com/yuin/gopher-lua / TestObjLen

Function TestObjLen

state_test.go:254–271  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

252}
253
254func TestObjLen(t *testing.T) {
255 L := NewState()
256 defer L.Close()
257 errorIfNotEqual(t, 3, L.ObjLen(LString("abc")))
258 tbl := L.NewTable()
259 tbl.Append(LTrue)
260 tbl.Append(LTrue)
261 errorIfNotEqual(t, 2, L.ObjLen(tbl))
262 mt := L.NewTable()
263 L.SetField(mt, "__len", L.NewFunction(func(L *LState) int {
264 tbl := L.CheckTable(1)
265 L.Push(LNumber(tbl.Len() + 1))
266 return 1
267 }))
268 L.SetMetatable(tbl, mt)
269 errorIfNotEqual(t, 3, L.ObjLen(tbl))
270 errorIfNotEqual(t, 0, L.ObjLen(LNumber(10)))
271}
272
273func TestConcat(t *testing.T) {
274 L := NewState()

Callers

nothing calls this directly

Calls 14

errorIfNotEqualFunction · 0.85
LStringTypeAlias · 0.85
LNumberTypeAlias · 0.85
AppendMethod · 0.80
CheckTableMethod · 0.80
NewStateFunction · 0.70
PushMethod · 0.65
CloseMethod · 0.45
ObjLenMethod · 0.45
NewTableMethod · 0.45
SetFieldMethod · 0.45
NewFunctionMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…