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/lists.lua | |
| parent | a19b242cbaf53721b20a3163dd06f43e9ef2b487 (diff) | |
| download | yuescript-60a979e224f26117f5be82bfca757a2483cef0fd.tar.gz yuescript-60a979e224f26117f5be82bfca757a2483cef0fd.tar.bz2 yuescript-60a979e224f26117f5be82bfca757a2483cef0fd.zip | |
fix test.
Diffstat (limited to 'spec/outputs/lists.lua')
| -rw-r--r-- | spec/outputs/lists.lua | 282 |
1 files changed, 282 insertions, 0 deletions
diff --git a/spec/outputs/lists.lua b/spec/outputs/lists.lua new file mode 100644 index 0000000..581cc23 --- /dev/null +++ b/spec/outputs/lists.lua | |||
| @@ -0,0 +1,282 @@ | |||
| 1 | local hi | ||
| 2 | do | ||
| 3 | local _accum_0 = { } | ||
| 4 | local _len_0 = 1 | ||
| 5 | for _, x in ipairs({ | ||
| 6 | 1, | ||
| 7 | 2, | ||
| 8 | 3, | ||
| 9 | 4 | ||
| 10 | }) do | ||
| 11 | _accum_0[_len_0] = x * 2 | ||
| 12 | _len_0 = _len_0 + 1 | ||
| 13 | end | ||
| 14 | hi = _accum_0 | ||
| 15 | end | ||
| 16 | local items = { | ||
| 17 | 1, | ||
| 18 | 2, | ||
| 19 | 3, | ||
| 20 | 4, | ||
| 21 | 5, | ||
| 22 | 6 | ||
| 23 | } | ||
| 24 | local _ | ||
| 25 | do | ||
| 26 | local _accum_0 = { } | ||
| 27 | local _len_0 = 1 | ||
| 28 | for z in ipairs(items) do | ||
| 29 | if z > 4 then | ||
| 30 | _accum_0[_len_0] = z | ||
| 31 | _len_0 = _len_0 + 1 | ||
| 32 | end | ||
| 33 | end | ||
| 34 | _ = _accum_0 | ||
| 35 | end | ||
| 36 | local rad | ||
| 37 | do | ||
| 38 | local _accum_0 = { } | ||
| 39 | local _len_0 = 1 | ||
| 40 | for a in ipairs({ | ||
| 41 | 1, | ||
| 42 | 2, | ||
| 43 | 3, | ||
| 44 | 4, | ||
| 45 | 5, | ||
| 46 | 6 | ||
| 47 | }) do | ||
| 48 | if good_number(a) then | ||
| 49 | _accum_0[_len_0] = { | ||
| 50 | a | ||
| 51 | } | ||
| 52 | _len_0 = _len_0 + 1 | ||
| 53 | end | ||
| 54 | end | ||
| 55 | rad = _accum_0 | ||
| 56 | end | ||
| 57 | do | ||
| 58 | local _accum_0 = { } | ||
| 59 | local _len_0 = 1 | ||
| 60 | for z in items do | ||
| 61 | for j in list do | ||
| 62 | if z > 4 then | ||
| 63 | _accum_0[_len_0] = z | ||
| 64 | _len_0 = _len_0 + 1 | ||
| 65 | end | ||
| 66 | end | ||
| 67 | end | ||
| 68 | _ = _accum_0 | ||
| 69 | end | ||
| 70 | require("util") | ||
| 71 | local dump | ||
| 72 | dump = function(x) | ||
| 73 | return print(util.dump(x)) | ||
| 74 | end | ||
| 75 | local range | ||
| 76 | range = function(count) | ||
| 77 | local i = 0 | ||
| 78 | return coroutine.wrap(function() | ||
| 79 | while i < count do | ||
| 80 | coroutine.yield(i) | ||
| 81 | i = i + 1 | ||
| 82 | end | ||
| 83 | end) | ||
| 84 | end | ||
| 85 | dump((function() | ||
| 86 | local _accum_0 = { } | ||
| 87 | local _len_0 = 1 | ||
| 88 | for x in range(10) do | ||
| 89 | _accum_0[_len_0] = x | ||
| 90 | _len_0 = _len_0 + 1 | ||
| 91 | end | ||
| 92 | return _accum_0 | ||
| 93 | end)()) | ||
| 94 | dump((function() | ||
| 95 | local _accum_0 = { } | ||
| 96 | local _len_0 = 1 | ||
| 97 | for x in range(5) do | ||
| 98 | if x > 2 then | ||
| 99 | for y in range(5) do | ||
| 100 | _accum_0[_len_0] = { | ||
| 101 | x, | ||
| 102 | y | ||
| 103 | } | ||
| 104 | _len_0 = _len_0 + 1 | ||
| 105 | end | ||
| 106 | end | ||
| 107 | end | ||
| 108 | return _accum_0 | ||
| 109 | end)()) | ||
| 110 | local things | ||
| 111 | do | ||
| 112 | local _accum_0 = { } | ||
| 113 | local _len_0 = 1 | ||
| 114 | for x in range(10) do | ||
| 115 | if x > 5 then | ||
| 116 | for y in range(10) do | ||
| 117 | if y > 7 then | ||
| 118 | _accum_0[_len_0] = x + y | ||
| 119 | _len_0 = _len_0 + 1 | ||
| 120 | end | ||
| 121 | end | ||
| 122 | end | ||
| 123 | end | ||
| 124 | things = _accum_0 | ||
| 125 | end | ||
| 126 | for x in ipairs({ | ||
| 127 | 1, | ||
| 128 | 2, | ||
| 129 | 4 | ||
| 130 | }) do | ||
| 131 | for y in ipairs({ | ||
| 132 | 1, | ||
| 133 | 2, | ||
| 134 | 3 | ||
| 135 | }) do | ||
| 136 | if x ~= 2 then | ||
| 137 | print(x, y) | ||
| 138 | end | ||
| 139 | end | ||
| 140 | end | ||
| 141 | for x in items do | ||
| 142 | print("hello", x) | ||
| 143 | end | ||
| 144 | do | ||
| 145 | local _accum_0 = { } | ||
| 146 | local _len_0 = 1 | ||
| 147 | for x in x do | ||
| 148 | _accum_0[_len_0] = x | ||
| 149 | _len_0 = _len_0 + 1 | ||
| 150 | end | ||
| 151 | _ = _accum_0 | ||
| 152 | end | ||
| 153 | local x | ||
| 154 | do | ||
| 155 | local _accum_0 = { } | ||
| 156 | local _len_0 = 1 | ||
| 157 | for x in x do | ||
| 158 | _accum_0[_len_0] = x | ||
| 159 | _len_0 = _len_0 + 1 | ||
| 160 | end | ||
| 161 | x = _accum_0 | ||
| 162 | end | ||
| 163 | for x in ipairs({ | ||
| 164 | 1, | ||
| 165 | 2, | ||
| 166 | 4 | ||
| 167 | }) do | ||
| 168 | for y in ipairs({ | ||
| 169 | 1, | ||
| 170 | 2, | ||
| 171 | 3 | ||
| 172 | }) do | ||
| 173 | if x ~= 2 then | ||
| 174 | print(x, y) | ||
| 175 | end | ||
| 176 | end | ||
| 177 | end | ||
| 178 | local double | ||
| 179 | do | ||
| 180 | local _accum_0 = { } | ||
| 181 | local _len_0 = 1 | ||
| 182 | for _index_0 = 1, #items do | ||
| 183 | local x = items[_index_0] | ||
| 184 | _accum_0[_len_0] = x * 2 | ||
| 185 | _len_0 = _len_0 + 1 | ||
| 186 | end | ||
| 187 | double = _accum_0 | ||
| 188 | end | ||
| 189 | for _index_0 = 1, #double do | ||
| 190 | local x = double[_index_0] | ||
| 191 | print(x) | ||
| 192 | end | ||
| 193 | local cut | ||
| 194 | do | ||
| 195 | local _accum_0 = { } | ||
| 196 | local _len_0 = 1 | ||
| 197 | for _index_0 = 1, #items do | ||
| 198 | local x = items[_index_0] | ||
| 199 | if x > 3 then | ||
| 200 | _accum_0[_len_0] = x | ||
| 201 | _len_0 = _len_0 + 1 | ||
| 202 | end | ||
| 203 | end | ||
| 204 | cut = _accum_0 | ||
| 205 | end | ||
| 206 | local hello | ||
| 207 | do | ||
| 208 | local _accum_0 = { } | ||
| 209 | local _len_0 = 1 | ||
| 210 | for _index_0 = 1, #items do | ||
| 211 | local x = items[_index_0] | ||
| 212 | for _index_1 = 1, #items do | ||
| 213 | local y = items[_index_1] | ||
| 214 | _accum_0[_len_0] = x + y | ||
| 215 | _len_0 = _len_0 + 1 | ||
| 216 | end | ||
| 217 | end | ||
| 218 | hello = _accum_0 | ||
| 219 | end | ||
| 220 | for _index_0 = 1, #hello do | ||
| 221 | local z = hello[_index_0] | ||
| 222 | print(z) | ||
| 223 | end | ||
| 224 | x = { | ||
| 225 | 1, | ||
| 226 | 2, | ||
| 227 | 3, | ||
| 228 | 4, | ||
| 229 | 5, | ||
| 230 | 6, | ||
| 231 | 7 | ||
| 232 | } | ||
| 233 | local _max_0 = -5 | ||
| 234 | for _index_0 = 2, _max_0 < 0 and #x + _max_0 or _max_0, 2 do | ||
| 235 | local y = x[_index_0] | ||
| 236 | print(y) | ||
| 237 | end | ||
| 238 | local _max_1 = 3 | ||
| 239 | for _index_0 = 1, _max_1 < 0 and #x + _max_1 or _max_1 do | ||
| 240 | local y = x[_index_0] | ||
| 241 | print(y) | ||
| 242 | end | ||
| 243 | for _index_0 = 2, #x do | ||
| 244 | local y = x[_index_0] | ||
| 245 | print(y) | ||
| 246 | end | ||
| 247 | for _index_0 = 1, #x, 2 do | ||
| 248 | local y = x[_index_0] | ||
| 249 | print(y) | ||
| 250 | end | ||
| 251 | for _index_0 = 2, #x, 2 do | ||
| 252 | local y = x[_index_0] | ||
| 253 | print(y) | ||
| 254 | end | ||
| 255 | local a, b, c = 1, 5, 2 | ||
| 256 | local _max_2 = b | ||
| 257 | for _index_0 = a, _max_2 < 0 and #x + _max_2 or _max_2, c do | ||
| 258 | local y = x[_index_0] | ||
| 259 | print(y) | ||
| 260 | end | ||
| 261 | local normal | ||
| 262 | normal = function(hello) | ||
| 263 | local _accum_0 = { } | ||
| 264 | local _len_0 = 1 | ||
| 265 | for x in yeah do | ||
| 266 | _accum_0[_len_0] = x | ||
| 267 | _len_0 = _len_0 + 1 | ||
| 268 | end | ||
| 269 | return _accum_0 | ||
| 270 | end | ||
| 271 | local test = x(1, 2, 3, 4, 5) | ||
| 272 | for _index_0 = 1, #test do | ||
| 273 | local thing = test[_index_0] | ||
| 274 | print(thing) | ||
| 275 | end | ||
| 276 | return function() | ||
| 277 | local _list_0 = rows | ||
| 278 | for _index_0 = 1, #_list_0 do | ||
| 279 | local row = _list_0[_index_0] | ||
| 280 | a = b | ||
| 281 | end | ||
| 282 | end | ||
