PageRenderTime 45ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Examples/test-suite/lua/li_std_pair_runme.lua

#
Lua | 34 lines | 23 code | 8 blank | 3 comment | 17 complexity | ac1a2d1370ae59d7bb327229c609c64d MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. require("import") -- the import fn
  2. import("li_std_pair") -- import code
  3. for k,v in pairs(li_std_pair) do _G[k]=v end -- move to global
  4. intPair = makeIntPair(7, 6)
  5. assert(intPair.first==7 and intPair.second==6)
  6. intPairPtr = makeIntPairPtr(7, 6)
  7. assert(intPairPtr.first==7 and intPairPtr.second==6)
  8. intPairRef = makeIntPairRef(7, 6)
  9. assert(intPairRef.first == 7 and intPairRef.second == 6)
  10. intPairConstRef = makeIntPairConstRef(7, 6)
  11. assert(intPairConstRef.first == 7 and intPairConstRef.second == 6)
  12. -- call fns
  13. assert(product1(intPair) == 42)
  14. assert(product2(intPair) == 42)
  15. assert(product3(intPair) == 42)
  16. -- also use the pointer version
  17. assert(product1(intPairPtr) == 42)
  18. assert(product2(intPairPtr) == 42)
  19. assert(product3(intPairPtr) == 42)
  20. -- or the other types
  21. assert(product1(intPairRef) == 42)
  22. assert(product2(intPairRef) == 42)
  23. assert(product3(intPairRef) == 42)
  24. assert(product1(intPairConstRef) == 42)
  25. assert(product2(intPairConstRef) == 42)
  26. assert(product3(intPairConstRef) == 42)