github.com/aergoio/aergo@v1.3.1/contract/measure/op.lua (about) 1 LLINE = "long line aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" 2 LLINE1 = "long line aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" 3 4 function comp_ops() 5 A = 2 6 D = 1 if A < D then 7 end 8 if A <= D then 9 end 10 if not (A < D) then 11 end 12 if not (A <= D) then 13 end 14 if A == D then 15 end 16 if not (A == D) then 17 end 18 V = "kslee" 19 if V == "kslee" then 20 end 21 if V ~= "a very long long long line" then 22 end 23 if LLINE ~= V then 24 end 25 if LLINE ~= LLINE1 then 26 end 27 if LLINE == LLINE1 then 28 end 29 if A == 2 then 30 end 31 if A ~= 1 then 32 end 33 B = true 34 if B == true then 35 end 36 if B ~= false then 37 end 38 end 39 40 local istc = function (b) 41 return b and 1 42 end 43 44 local isfc = function (b) 45 return b or 1 46 end 47 48 function unarytest_n_copy_ops() 49 -- 16, 17 50 NONE = nil 51 B = false 52 S = "kslee" 53 istc(true) 54 isfc(true) 55 if S and B then 56 end 57 if NONE or B then 58 end 59 if NONE or B then 60 end 61 B = true 62 if B or NONE then 63 end 64 end 65 66 function unary_ops() 67 D = 3 68 A = D 69 B = not A 70 N = -D 71 ARR = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 } 72 L = #ARR 73 S = "a very long long long line" 74 L = #S 75 end 76 77 function binary_ops() 78 A = 0 79 B = 2 80 A = B + 1 81 A = B - 1 82 A = B * 1 83 A = B / 1 84 A = B % 1 85 A = B + 1.2 86 A = B - 1.2 87 A = B * 1.2 88 A = B / 1.2 89 A = B % 1.2 90 A = 1 + B 91 A = 1 - B 92 A = 1 * B 93 A = 1 / B 94 A = 1 % B 95 A = 1.2 + B 96 A = 1.2 - B 97 A = 1.2 * B 98 A = 1.2 / B 99 A = 1.2 % B 100 C = 1 101 A = B + C 102 A = B - C 103 A = B * C 104 A = B / C 105 A = B % C 106 A = B ^ C 107 C = 1.2 108 A = B + C 109 A = B - C 110 A = B * C 111 A = B / C 112 A = B % C 113 A = B ^ C 114 S = "kslee" .. "1981" .. LLINE 115 end 116 117 function constant_ops() 118 A, B, C = nil, nil, nil 119 end 120 121 function upvalue_n_func_ops() 122 local U = "kslee" 123 F = function() U = U .. "1981"; return U end 124 F() 125 F = function() U = "1981" end 126 F() 127 local D = 100 128 F = function() D = 0 end 129 F() 130 local B = false 131 F = function() B = true end 132 F() 133 end 134 135 function f() 136 return 4 137 end 138 139 function table_ops() 140 -- deprecated(op code not found): TGETR(59), TSETR(64) 141 E = {} 142 T = { name = "kslee", age = 40, 1, 2, 3 } 143 K = "name" 144 NAME = T[K] 145 AGE = T.age 146 ONE = T[1] 147 I = 1 148 ONE = T[I] 149 T[K] = "kslee" 150 T.age = 41 151 T[4] = I 152 return { 1, 2, 3, f() } 153 end 154 155 function varg(...) 156 return ... 157 end 158 159 function fixed_varg(a, b, c, ...) 160 return a + b + c, ... 161 end 162 163 function call_n_vararg_ops() 164 varg("kslee", "1981", 41) 165 T = 0 166 ARR = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 } 167 for i, v in ipairs(ARR) do 168 T = T + v 169 end 170 ARR.name = "kslee" 171 for k, v in pairs(ARR) do 172 if type(k) == 'number' then 173 T = T + v 174 end 175 end 176 local x, y, z = fixed_varg(1, 2, 3, varg("kslee", "1981", 41)) 177 return fixed_varg(1, 2, 3, varg("kslee", "1981", 41)) 178 end 179 180 function swap(x, y) 181 return y, x 182 end 183 184 function return_ops() 185 return swap(1, 2) 186 end 187 188 function range_iter(n, i) 189 if i >= n then 190 return nil, nil 191 end 192 return i+1, i+1 193 end 194 195 function range(n) 196 return range_iter, n, 0 197 end 198 199 function loop_n_branche_ops() 200 -- IFORL(80), IITERL(83) 201 local T = 0 202 for i = 1, 100 do 203 T = T + i 204 end 205 for n in range(100) do 206 T = T + n 207 end 208 local i = 0 209 while true do 210 i = i + 1 211 if i == 100 then 212 break 213 end 214 end 215 end 216 217 function function_header_ops() 218 -- FUNCF(89), IFUNCV(93), FUNCCW(96) 219 end 220 221 for i = 1, 1000 do 222 comp_ops() 223 unarytest_n_copy_ops() 224 unary_ops() 225 binary_ops() 226 constant_ops() 227 upvalue_n_func_ops() 228 table_ops() 229 call_n_vararg_ops() 230 return_ops() 231 loop_n_branche_ops() 232 function_header_ops() 233 end 234