MCPcopy Create free account
hub / github.com/defold/defold / SetupCyclicTable

Function SetupCyclicTable

engine/script/src/test/test_script_table.cpp:461–488  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

459}
460
461static void SetupCyclicTable(lua_State* L)
462{
463 /**
464 * local x1 = {}
465 * local x2 = {}
466 * x1.x2 = x2
467 * x2.x1 = x1
468 */
469
470 lua_newtable(L); // x1
471 // -1: x1
472
473 lua_newtable(L); // x2
474 // -2: x1
475 // -1: x2
476
477 lua_pushvalue(L, -2);
478 // -3: x1
479 // -2: x2
480 // -1: x1
481
482 lua_setfield(L, -2, "x1"); // x2.x1 = x1
483 // -2: x1
484 // -1: x2
485
486 lua_setfield(L, -2, "x2"); // x1.x2 = x2
487 // -1: x1
488}
489
490TEST_F(LuaTableTest, CyclicTable_CheckTableSize)
491{

Callers 1

TEST_FFunction · 0.85

Calls 2

lua_pushvalueFunction · 0.85
lua_setfieldFunction · 0.85

Tested by

no test coverage detected