diff options
| author | Li Jin <dragon-fly@qq.com> | 2021-10-12 10:04:44 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2021-10-12 10:04:44 +0800 |
| commit | 60a979e224f26117f5be82bfca757a2483cef0fd (patch) | |
| tree | 7c6af44f6dcada1f23979b820ba830251997b161 /spec/outputs/export.lua | |
| parent | a19b242cbaf53721b20a3163dd06f43e9ef2b487 (diff) | |
| download | yuescript-60a979e224f26117f5be82bfca757a2483cef0fd.tar.gz yuescript-60a979e224f26117f5be82bfca757a2483cef0fd.tar.bz2 yuescript-60a979e224f26117f5be82bfca757a2483cef0fd.zip | |
fix test.
Diffstat (limited to 'spec/outputs/export.lua')
| -rw-r--r-- | spec/outputs/export.lua | 307 |
1 files changed, 307 insertions, 0 deletions
diff --git a/spec/outputs/export.lua b/spec/outputs/export.lua new file mode 100644 index 0000000..02546ec --- /dev/null +++ b/spec/outputs/export.lua | |||
| @@ -0,0 +1,307 @@ | |||
| 1 | local _module_0 = { } | ||
| 2 | local a, b, c = 223, 343, 123 | ||
| 3 | _module_0["a"], _module_0["b"], _module_0["c"] = a, b, c | ||
| 4 | local cool = "dad" | ||
| 5 | _module_0["cool"] = cool | ||
| 6 | local d, e, f = 3, 2, 1 | ||
| 7 | _module_0[#_module_0 + 1] = d | ||
| 8 | _module_0[#_module_0 + 1] = e | ||
| 9 | _module_0[#_module_0 + 1] = f | ||
| 10 | local Something | ||
| 11 | do | ||
| 12 | local _class_0 | ||
| 13 | local _base_0 = { | ||
| 14 | umm = "cool" | ||
| 15 | } | ||
| 16 | _base_0.__index = _base_0 | ||
| 17 | _class_0 = setmetatable({ | ||
| 18 | __init = function() end, | ||
| 19 | __base = _base_0, | ||
| 20 | __name = "Something" | ||
| 21 | }, { | ||
| 22 | __index = _base_0, | ||
| 23 | __call = function(cls, ...) | ||
| 24 | local _self_0 = setmetatable({ }, _base_0) | ||
| 25 | cls.__init(_self_0, ...) | ||
| 26 | return _self_0 | ||
| 27 | end | ||
| 28 | }) | ||
| 29 | _base_0.__class = _class_0 | ||
| 30 | Something = _class_0 | ||
| 31 | end | ||
| 32 | _module_0["Something"] = Something | ||
| 33 | if this then | ||
| 34 | _module_0[#_module_0 + 1] = 232 | ||
| 35 | else | ||
| 36 | _module_0[#_module_0 + 1] = 4343 | ||
| 37 | end | ||
| 38 | local What | ||
| 39 | if this then | ||
| 40 | What = 232 | ||
| 41 | else | ||
| 42 | What = 4343 | ||
| 43 | end | ||
| 44 | _module_0["What"] = What | ||
| 45 | local y | ||
| 46 | y = function() | ||
| 47 | local hallo = 3434 | ||
| 48 | end | ||
| 49 | _module_0["y"] = y | ||
| 50 | do | ||
| 51 | local _with_0 = tmp | ||
| 52 | local j = 2000 | ||
| 53 | _module_0[#_module_0 + 1] = _with_0 | ||
| 54 | end | ||
| 55 | local cbVal | ||
| 56 | do | ||
| 57 | local h = 100 | ||
| 58 | cbVal = f(function(x) | ||
| 59 | return x(h) | ||
| 60 | end) | ||
| 61 | end | ||
| 62 | _module_0["cbVal"] = cbVal | ||
| 63 | y = function() | ||
| 64 | local h = 100 | ||
| 65 | local k = 100 | ||
| 66 | end | ||
| 67 | _module_0["y"] = y | ||
| 68 | local _exp_0 = h | ||
| 69 | if 100 == _exp_0 or 150 == _exp_0 then | ||
| 70 | _module_0[#_module_0 + 1] = 200 | ||
| 71 | elseif 200 == _exp_0 then | ||
| 72 | _module_0[#_module_0 + 1] = 300 | ||
| 73 | else | ||
| 74 | _module_0[#_module_0 + 1] = 0 | ||
| 75 | end | ||
| 76 | local Constant | ||
| 77 | local _exp_1 = value | ||
| 78 | if "good" == _exp_1 then | ||
| 79 | Constant = 1 | ||
| 80 | elseif "better" == _exp_1 then | ||
| 81 | Constant = 2 | ||
| 82 | elseif "best" == _exp_1 then | ||
| 83 | Constant = 3 | ||
| 84 | end | ||
| 85 | _module_0["Constant"] = Constant | ||
| 86 | local item = func(123) | ||
| 87 | _module_0["item"] = item | ||
| 88 | _module_0[#_module_0 + 1] = x | ||
| 89 | f((function() | ||
| 90 | if a then | ||
| 91 | return b | ||
| 92 | end | ||
| 93 | end)()) | ||
| 94 | f((function() | ||
| 95 | return 123 | ||
| 96 | end)()) | ||
| 97 | f((function() | ||
| 98 | if b == a then | ||
| 99 | return c | ||
| 100 | end | ||
| 101 | end)()) | ||
| 102 | f((function() | ||
| 103 | local _accum_0 = { } | ||
| 104 | local _len_0 = 1 | ||
| 105 | for i = 1, 10 do | ||
| 106 | _accum_0[_len_0] = i | ||
| 107 | _len_0 = _len_0 + 1 | ||
| 108 | end | ||
| 109 | return _accum_0 | ||
| 110 | end)()) | ||
| 111 | f((function() | ||
| 112 | local _accum_0 = { } | ||
| 113 | local _len_0 = 1 | ||
| 114 | for i = 1, 10 do | ||
| 115 | _accum_0[_len_0] = i | ||
| 116 | _len_0 = _len_0 + 1 | ||
| 117 | end | ||
| 118 | return _accum_0 | ||
| 119 | end)()) | ||
| 120 | f((function() | ||
| 121 | local _tbl_0 = { } | ||
| 122 | for k, v in pairs(tb) do | ||
| 123 | _tbl_0[k] = v | ||
| 124 | end | ||
| 125 | return _tbl_0 | ||
| 126 | end)()) | ||
| 127 | f((function() | ||
| 128 | local _accum_0 = { } | ||
| 129 | local _len_0 = 1 | ||
| 130 | for k, v in pairs(tb) do | ||
| 131 | _accum_0[_len_0] = k, v | ||
| 132 | _len_0 = _len_0 + 1 | ||
| 133 | end | ||
| 134 | return _accum_0 | ||
| 135 | end)()) | ||
| 136 | f((function() | ||
| 137 | local _accum_0 = { } | ||
| 138 | local _len_0 = 1 | ||
| 139 | while a do | ||
| 140 | _accum_0[_len_0] = true | ||
| 141 | _len_0 = _len_0 + 1 | ||
| 142 | end | ||
| 143 | return _accum_0 | ||
| 144 | end)()) | ||
| 145 | f((function() | ||
| 146 | a.b = 123 | ||
| 147 | return a | ||
| 148 | end)()) | ||
| 149 | f((function() | ||
| 150 | if a ~= nil then | ||
| 151 | return a.b | ||
| 152 | end | ||
| 153 | return nil | ||
| 154 | end)()) | ||
| 155 | f((function() | ||
| 156 | local _base_0 = a | ||
| 157 | local _fn_0 = _base_0.b | ||
| 158 | return _fn_0 and function(...) | ||
| 159 | return _fn_0(_base_0, ...) | ||
| 160 | end | ||
| 161 | end)()) | ||
| 162 | f((function() | ||
| 163 | local A | ||
| 164 | do | ||
| 165 | local _class_0 | ||
| 166 | local _base_0 = { } | ||
| 167 | _base_0.__index = _base_0 | ||
| 168 | _class_0 = setmetatable({ | ||
| 169 | __init = function() end, | ||
| 170 | __base = _base_0, | ||
| 171 | __name = "A" | ||
| 172 | }, { | ||
| 173 | __index = _base_0, | ||
| 174 | __call = function(cls, ...) | ||
| 175 | local _self_0 = setmetatable({ }, _base_0) | ||
| 176 | cls.__init(_self_0, ...) | ||
| 177 | return _self_0 | ||
| 178 | end | ||
| 179 | }) | ||
| 180 | _base_0.__class = _class_0 | ||
| 181 | A = _class_0 | ||
| 182 | return _class_0 | ||
| 183 | end | ||
| 184 | end)()) | ||
| 185 | local _ = tostring((function() | ||
| 186 | if a then | ||
| 187 | return b | ||
| 188 | end | ||
| 189 | end)()) | ||
| 190 | _ = tostring((function() | ||
| 191 | return 123 | ||
| 192 | end)()) | ||
| 193 | _ = tostring((function() | ||
| 194 | if b == a then | ||
| 195 | return c | ||
| 196 | end | ||
| 197 | end)()) | ||
| 198 | _ = tostring((function() | ||
| 199 | local _accum_0 = { } | ||
| 200 | local _len_0 = 1 | ||
| 201 | for i = 1, 10 do | ||
| 202 | _accum_0[_len_0] = i | ||
| 203 | _len_0 = _len_0 + 1 | ||
| 204 | end | ||
| 205 | return _accum_0 | ||
| 206 | end)()) | ||
| 207 | _ = tostring((function() | ||
| 208 | local _accum_0 = { } | ||
| 209 | local _len_0 = 1 | ||
| 210 | for i = 1, 10 do | ||
| 211 | _accum_0[_len_0] = i | ||
| 212 | _len_0 = _len_0 + 1 | ||
| 213 | end | ||
| 214 | return _accum_0 | ||
| 215 | end)()) | ||
| 216 | _ = tostring((function() | ||
| 217 | local _tbl_0 = { } | ||
| 218 | for k, v in pairs(tb) do | ||
| 219 | _tbl_0[k] = v | ||
| 220 | end | ||
| 221 | return _tbl_0 | ||
| 222 | end)()) | ||
| 223 | _ = tostring((function() | ||
| 224 | local _accum_0 = { } | ||
| 225 | local _len_0 = 1 | ||
| 226 | for k, v in pairs(tb) do | ||
| 227 | _accum_0[_len_0] = k, v | ||
| 228 | _len_0 = _len_0 + 1 | ||
| 229 | end | ||
| 230 | return _accum_0 | ||
| 231 | end)()) | ||
| 232 | _ = tostring((function() | ||
| 233 | local _accum_0 = { } | ||
| 234 | local _len_0 = 1 | ||
| 235 | while a do | ||
| 236 | _accum_0[_len_0] = true | ||
| 237 | _len_0 = _len_0 + 1 | ||
| 238 | end | ||
| 239 | return _accum_0 | ||
| 240 | end)()) | ||
| 241 | _ = tostring((function() | ||
| 242 | a.b = 123 | ||
| 243 | return a | ||
| 244 | end)()) | ||
| 245 | _ = tostring((function() | ||
| 246 | if a ~= nil then | ||
| 247 | return a.b | ||
| 248 | end | ||
| 249 | return nil | ||
| 250 | end)()) | ||
| 251 | _ = tostring((function() | ||
| 252 | local _base_0 = a | ||
| 253 | local _fn_0 = _base_0.b | ||
| 254 | return _fn_0 and function(...) | ||
| 255 | return _fn_0(_base_0, ...) | ||
| 256 | end | ||
| 257 | end)()) | ||
| 258 | _ = tostring((function() | ||
| 259 | local A | ||
| 260 | do | ||
| 261 | local _class_0 | ||
| 262 | local _base_0 = { } | ||
| 263 | _base_0.__index = _base_0 | ||
| 264 | _class_0 = setmetatable({ | ||
| 265 | __init = function() end, | ||
| 266 | __base = _base_0, | ||
| 267 | __name = "A" | ||
| 268 | }, { | ||
| 269 | __index = _base_0, | ||
| 270 | __call = function(cls, ...) | ||
| 271 | local _self_0 = setmetatable({ }, _base_0) | ||
| 272 | cls.__init(_self_0, ...) | ||
| 273 | return _self_0 | ||
| 274 | end | ||
| 275 | }) | ||
| 276 | _base_0.__class = _class_0 | ||
| 277 | A = _class_0 | ||
| 278 | return _class_0 | ||
| 279 | end | ||
| 280 | end)()) | ||
| 281 | local v1, v2, v3, v4, v5 | ||
| 282 | v1 = 1 | ||
| 283 | v2 = 2 | ||
| 284 | _module_0["v2"] = v2 | ||
| 285 | do | ||
| 286 | local _class_0 | ||
| 287 | local _base_0 = { } | ||
| 288 | _base_0.__index = _base_0 | ||
| 289 | _class_0 = setmetatable({ | ||
| 290 | __init = function() end, | ||
| 291 | __base = _base_0, | ||
| 292 | __name = "v4" | ||
| 293 | }, { | ||
| 294 | __index = _base_0, | ||
| 295 | __call = function(cls, ...) | ||
| 296 | local _self_0 = setmetatable({ }, _base_0) | ||
| 297 | cls.__init(_self_0, ...) | ||
| 298 | return _self_0 | ||
| 299 | end | ||
| 300 | }) | ||
| 301 | _base_0.__class = _class_0 | ||
| 302 | v4 = _class_0 | ||
| 303 | v3 = _class_0 | ||
| 304 | end | ||
| 305 | _module_0["v3"] = v3 | ||
| 306 | v5 = 5 | ||
| 307 | return _module_0 | ||
