GE Lua Documentation

Press F to search!

testBindings

Definition


-- @/lua/common/luaBinding.lua:249

function testBindings()
  print(' *** Unittest start ***')
  local a = TestNamespace.TestClassA()
  a.strC = 'this is C'
  a:callC()
  a.strB = 'abc'
  assert(a.strB == 'abc')
  assert(pcall(function() a:callC() end) == true)

  --assert(pcall(function() tc.strC = 'test' end) == false) -- this will fail as tc is declared as const
  --assert(pcall(function() tc:callA() end) == false) -- will not work as the function is not const
  --assert(pcall(function() tc:callC() end) == true) -- will work as the fucntion is declared as const: void callC() const;

  -- destruction tests
  local tmp = {}
  for i = 0, 5 do
    table.insert(tmp, TestNamespace.TestClassB())
  end
  tmp = nil -- free everything
  collectgarbage("collect")
  collectgarbage("collect")
  collectgarbage("collect")

  print(' *** DONE ***')
end

Callers