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) 35