(t *testing.T)
| 252 | } |
| 253 | |
| 254 | func 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 | |
| 273 | func TestConcat(t *testing.T) { |
| 274 | L := NewState() |
nothing calls this directly
no test coverage detected
searching dependent graphs…