PageRenderTime 20ms CodeModel.GetById 13ms app.highlight 6ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/rel-1.3.35/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
 1require("import")	-- the import fn
 2import("li_std_pair")	-- import code
 3
 4for k,v in pairs(li_std_pair) do _G[k]=v end -- move to global
 5
 6intPair = makeIntPair(7, 6)
 7assert(intPair.first==7 and intPair.second==6)
 8
 9intPairPtr = makeIntPairPtr(7, 6)
10assert(intPairPtr.first==7 and intPairPtr.second==6)
11
12intPairRef = makeIntPairRef(7, 6)
13assert(intPairRef.first == 7 and intPairRef.second == 6)
14
15intPairConstRef = makeIntPairConstRef(7, 6)
16assert(intPairConstRef.first == 7 and intPairConstRef.second == 6)
17
18-- call fns
19assert(product1(intPair) == 42)
20assert(product2(intPair) == 42)
21assert(product3(intPair) == 42)
22
23-- also use the pointer version
24assert(product1(intPairPtr) == 42)
25assert(product2(intPairPtr) == 42)
26assert(product3(intPairPtr) == 42)
27
28-- or the other types
29assert(product1(intPairRef) == 42)
30assert(product2(intPairRef) == 42)
31assert(product3(intPairRef) == 42)
32assert(product1(intPairConstRef) == 42)
33assert(product2(intPairConstRef) == 42)
34assert(product3(intPairConstRef) == 42)