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/loops.lua | |
| parent | a19b242cbaf53721b20a3163dd06f43e9ef2b487 (diff) | |
| download | yuescript-60a979e224f26117f5be82bfca757a2483cef0fd.tar.gz yuescript-60a979e224f26117f5be82bfca757a2483cef0fd.tar.bz2 yuescript-60a979e224f26117f5be82bfca757a2483cef0fd.zip | |
fix test.
Diffstat (limited to 'spec/outputs/loops.lua')
| -rw-r--r-- | spec/outputs/loops.lua | 352 |
1 files changed, 352 insertions, 0 deletions
diff --git a/spec/outputs/loops.lua b/spec/outputs/loops.lua new file mode 100644 index 0000000..a905e4e --- /dev/null +++ b/spec/outputs/loops.lua | |||
| @@ -0,0 +1,352 @@ | |||
| 1 | for x = 1, 10 do | ||
| 2 | print("yeah") | ||
| 3 | end | ||
| 4 | for x = 1, #something do | ||
| 5 | print("yeah") | ||
| 6 | end | ||
| 7 | for y = 100, 60, -3 do | ||
| 8 | print("count down", y) | ||
| 9 | end | ||
| 10 | for a = 1, 10 do | ||
| 11 | print("okay") | ||
| 12 | end | ||
| 13 | for a = 1, 10 do | ||
| 14 | for b = 2, 43 do | ||
| 15 | print(a, b) | ||
| 16 | end | ||
| 17 | end | ||
| 18 | for i in iter do | ||
| 19 | for j in yeah do | ||
| 20 | local x = 343 + i + j | ||
| 21 | print(i, j) | ||
| 22 | end | ||
| 23 | end | ||
| 24 | local _list_0 = something | ||
| 25 | for _index_0 = 1, #_list_0 do | ||
| 26 | local x = _list_0[_index_0] | ||
| 27 | print(x) | ||
| 28 | end | ||
| 29 | for k, v in pairs(hello) do | ||
| 30 | print(k, v) | ||
| 31 | end | ||
| 32 | for x in y, z do | ||
| 33 | print(x) | ||
| 34 | end | ||
| 35 | for x in y, z, k do | ||
| 36 | print(x) | ||
| 37 | end | ||
| 38 | local _list_1 = modules | ||
| 39 | for _index_0 = 1, #_list_1 do | ||
| 40 | local name, members = _list_1[_index_0] | ||
| 41 | print(name, member) | ||
| 42 | end | ||
| 43 | local x | ||
| 44 | x = function() | ||
| 45 | for x in y do | ||
| 46 | local _ = y | ||
| 47 | end | ||
| 48 | end | ||
| 49 | local hello = { | ||
| 50 | 1, | ||
| 51 | 2, | ||
| 52 | 3, | ||
| 53 | 4, | ||
| 54 | 5 | ||
| 55 | } | ||
| 56 | do | ||
| 57 | local _accum_0 = { } | ||
| 58 | local _len_0 = 1 | ||
| 59 | for _index_0 = 1, #hello do | ||
| 60 | local y = hello[_index_0] | ||
| 61 | if y % 2 == 0 then | ||
| 62 | _accum_0[_len_0] = y | ||
| 63 | end | ||
| 64 | _len_0 = _len_0 + 1 | ||
| 65 | end | ||
| 66 | x = _accum_0 | ||
| 67 | end | ||
| 68 | x = function() | ||
| 69 | for _index_0 = 1, #hello do | ||
| 70 | local x = hello[_index_0] | ||
| 71 | local _ = y | ||
| 72 | end | ||
| 73 | end | ||
| 74 | local t | ||
| 75 | do | ||
| 76 | local _accum_0 = { } | ||
| 77 | local _len_0 = 1 | ||
| 78 | for i = 10, 20 do | ||
| 79 | _accum_0[_len_0] = i * 2 | ||
| 80 | _len_0 = _len_0 + 1 | ||
| 81 | end | ||
| 82 | t = _accum_0 | ||
| 83 | end | ||
| 84 | local hmm = 0 | ||
| 85 | local y | ||
| 86 | do | ||
| 87 | local _accum_0 = { } | ||
| 88 | local _len_0 = 1 | ||
| 89 | for j = 3, 30, 8 do | ||
| 90 | hmm = hmm + 1 | ||
| 91 | _accum_0[_len_0] = j * hmm | ||
| 92 | _len_0 = _len_0 + 1 | ||
| 93 | end | ||
| 94 | y = _accum_0 | ||
| 95 | end | ||
| 96 | local _ | ||
| 97 | _ = function() | ||
| 98 | for k = 10, 40 do | ||
| 99 | _ = "okay" | ||
| 100 | end | ||
| 101 | end | ||
| 102 | _ = function() | ||
| 103 | local _accum_0 = { } | ||
| 104 | local _len_0 = 1 | ||
| 105 | for k = 10, 40 do | ||
| 106 | _accum_0[_len_0] = "okay" | ||
| 107 | _len_0 = _len_0 + 1 | ||
| 108 | end | ||
| 109 | return _accum_0 | ||
| 110 | end | ||
| 111 | while true do | ||
| 112 | print("name") | ||
| 113 | end | ||
| 114 | while 5 + 5 do | ||
| 115 | print("okay world") | ||
| 116 | working(man) | ||
| 117 | end | ||
| 118 | while also do | ||
| 119 | i(work(too)) | ||
| 120 | _ = "okay" | ||
| 121 | end | ||
| 122 | local i = 0 | ||
| 123 | do | ||
| 124 | local _accum_0 = { } | ||
| 125 | local _len_0 = 1 | ||
| 126 | while i < 10 do | ||
| 127 | i = i + 1 | ||
| 128 | _len_0 = _len_0 + 1 | ||
| 129 | end | ||
| 130 | x = _accum_0 | ||
| 131 | end | ||
| 132 | do | ||
| 133 | local _accum_0 = { } | ||
| 134 | local _len_0 = 1 | ||
| 135 | local _list_2 = 3 | ||
| 136 | for _index_0 = 1, #_list_2 do | ||
| 137 | local thing = _list_2[_index_0] | ||
| 138 | y = "hello" | ||
| 139 | _len_0 = _len_0 + 1 | ||
| 140 | end | ||
| 141 | x = _accum_0 | ||
| 142 | end | ||
| 143 | do | ||
| 144 | local _accum_0 = { } | ||
| 145 | local _len_0 = 1 | ||
| 146 | for x = 1, 2 do | ||
| 147 | y = "hello" | ||
| 148 | _len_0 = _len_0 + 1 | ||
| 149 | end | ||
| 150 | x = _accum_0 | ||
| 151 | end | ||
| 152 | while true do | ||
| 153 | local _continue_0 = false | ||
| 154 | repeat | ||
| 155 | if false then | ||
| 156 | _continue_0 = true | ||
| 157 | break | ||
| 158 | end | ||
| 159 | print("yes") | ||
| 160 | if true then | ||
| 161 | break | ||
| 162 | end | ||
| 163 | print("no") | ||
| 164 | _continue_0 = true | ||
| 165 | until true | ||
| 166 | if not _continue_0 then | ||
| 167 | break | ||
| 168 | end | ||
| 169 | end | ||
| 170 | for i = 1, 10 do | ||
| 171 | while true do | ||
| 172 | local _continue_0 = false | ||
| 173 | repeat | ||
| 174 | if not true then | ||
| 175 | _continue_0 = true | ||
| 176 | break | ||
| 177 | end | ||
| 178 | break | ||
| 179 | _continue_0 = true | ||
| 180 | until true | ||
| 181 | if not _continue_0 then | ||
| 182 | break | ||
| 183 | end | ||
| 184 | end | ||
| 185 | end | ||
| 186 | local a = 1 | ||
| 187 | repeat | ||
| 188 | local _continue_0 = false | ||
| 189 | repeat | ||
| 190 | a = a + 1 | ||
| 191 | if a == 5 then | ||
| 192 | _continue_0 = true | ||
| 193 | break | ||
| 194 | end | ||
| 195 | if a == 6 then | ||
| 196 | break | ||
| 197 | end | ||
| 198 | print(a) | ||
| 199 | _continue_0 = true | ||
| 200 | until true | ||
| 201 | if not _continue_0 then | ||
| 202 | break | ||
| 203 | end | ||
| 204 | until a == 10 | ||
| 205 | a = 3 | ||
| 206 | while not (a == 0) do | ||
| 207 | a = a - 1 | ||
| 208 | end | ||
| 209 | local done = false | ||
| 210 | while not done do | ||
| 211 | done = true | ||
| 212 | end | ||
| 213 | repeat | ||
| 214 | print("hello") | ||
| 215 | until true | ||
| 216 | while not done do | ||
| 217 | x = 10 | ||
| 218 | repeat | ||
| 219 | x = x - 1 | ||
| 220 | until x == 0 | ||
| 221 | end | ||
| 222 | while not cond do | ||
| 223 | print("okay") | ||
| 224 | end | ||
| 225 | for x = 1, 10 do | ||
| 226 | local _continue_0 = false | ||
| 227 | repeat | ||
| 228 | if x > 3 and x < 7 then | ||
| 229 | _continue_0 = true | ||
| 230 | break | ||
| 231 | end | ||
| 232 | print(x) | ||
| 233 | _continue_0 = true | ||
| 234 | until true | ||
| 235 | if not _continue_0 then | ||
| 236 | break | ||
| 237 | end | ||
| 238 | end | ||
| 239 | local list | ||
| 240 | do | ||
| 241 | local _accum_0 = { } | ||
| 242 | local _len_0 = 1 | ||
| 243 | for x = 1, 10 do | ||
| 244 | local _continue_0 = false | ||
| 245 | repeat | ||
| 246 | if x > 3 and x < 7 then | ||
| 247 | _continue_0 = true | ||
| 248 | break | ||
| 249 | end | ||
| 250 | _accum_0[_len_0] = x | ||
| 251 | _len_0 = _len_0 + 1 | ||
| 252 | _continue_0 = true | ||
| 253 | until true | ||
| 254 | if not _continue_0 then | ||
| 255 | break | ||
| 256 | end | ||
| 257 | end | ||
| 258 | list = _accum_0 | ||
| 259 | end | ||
| 260 | local _list_2 = { | ||
| 261 | 1, | ||
| 262 | 2, | ||
| 263 | 3, | ||
| 264 | 4, | ||
| 265 | 5, | ||
| 266 | 6 | ||
| 267 | } | ||
| 268 | for _index_0 = 1, #_list_2 do | ||
| 269 | local a = _list_2[_index_0] | ||
| 270 | local _continue_0 = false | ||
| 271 | repeat | ||
| 272 | if a == 1 then | ||
| 273 | _continue_0 = true | ||
| 274 | break | ||
| 275 | end | ||
| 276 | if a == 3 then | ||
| 277 | _continue_0 = true | ||
| 278 | break | ||
| 279 | end | ||
| 280 | print(a) | ||
| 281 | _continue_0 = true | ||
| 282 | until true | ||
| 283 | if not _continue_0 then | ||
| 284 | break | ||
| 285 | end | ||
| 286 | end | ||
| 287 | for x = 1, 10 do | ||
| 288 | local _continue_0 = false | ||
| 289 | repeat | ||
| 290 | if x % 2 == 0 then | ||
| 291 | _continue_0 = true | ||
| 292 | break | ||
| 293 | end | ||
| 294 | for y = 2, 12 do | ||
| 295 | local _continue_1 = false | ||
| 296 | repeat | ||
| 297 | if y % 3 == 0 then | ||
| 298 | _continue_1 = true | ||
| 299 | break | ||
| 300 | end | ||
| 301 | _continue_1 = true | ||
| 302 | until true | ||
| 303 | if not _continue_1 then | ||
| 304 | break | ||
| 305 | end | ||
| 306 | end | ||
| 307 | _continue_0 = true | ||
| 308 | until true | ||
| 309 | if not _continue_0 then | ||
| 310 | break | ||
| 311 | end | ||
| 312 | end | ||
| 313 | while true do | ||
| 314 | local _continue_0 = false | ||
| 315 | repeat | ||
| 316 | if false then | ||
| 317 | _continue_0 = true | ||
| 318 | break | ||
| 319 | end | ||
| 320 | break | ||
| 321 | _continue_0 = true | ||
| 322 | until true | ||
| 323 | if not _continue_0 then | ||
| 324 | break | ||
| 325 | end | ||
| 326 | end | ||
| 327 | while true do | ||
| 328 | local _continue_0 = false | ||
| 329 | repeat | ||
| 330 | if false then | ||
| 331 | _continue_0 = true | ||
| 332 | break | ||
| 333 | end | ||
| 334 | return 22 | ||
| 335 | _continue_0 = true | ||
| 336 | until true | ||
| 337 | if not _continue_0 then | ||
| 338 | break | ||
| 339 | end | ||
| 340 | end | ||
| 341 | do | ||
| 342 | local xxx = { | ||
| 343 | 1, | ||
| 344 | 2, | ||
| 345 | 3, | ||
| 346 | 4 | ||
| 347 | } | ||
| 348 | for _index_0 = 1, #xxx do | ||
| 349 | local thing = xxx[_index_0] | ||
| 350 | print(thing) | ||
| 351 | end | ||
| 352 | end | ||
