@@ -183,6 +183,76 @@ export class LuaLoopTests {
183183 Expect ( result ) . toBe ( JSON . stringify ( expected ) ) ;
184184 }
185185
186+ @TestCase ( [ 0 , 1 , 2 , 3 ] , [ 1 , 2 , 3 , 4 ] )
187+ @Test ( "forNoDeclarations" )
188+ public forNoDeclarations ( inp : number [ ] , expected : number [ ] ) : void {
189+ // Transpile
190+ const lua = util . transpileString (
191+ `let arrTest = ${ JSON . stringify ( inp ) } ;
192+ let i = 0;
193+ for (; i < arrTest.length; ++i) {
194+ arrTest[i] = arrTest[i] + 1;
195+ }
196+ return JSONStringify(arrTest);`
197+ ) ;
198+
199+ // Execute
200+ const result = util . executeLua ( lua ) ;
201+
202+ // Assert
203+ Expect ( result ) . toBe ( JSON . stringify ( expected ) ) ;
204+ }
205+
206+ @TestCase ( [ 0 , 1 , 2 , 3 ] , [ 1 , 2 , 3 , 4 ] )
207+ @Test ( "forNoCondition" )
208+ public forNoCondition ( inp : number [ ] , expected : number [ ] ) : void {
209+ // Transpile
210+ const lua = util . transpileString (
211+ `let arrTest = ${ JSON . stringify ( inp ) } ;
212+ let i = 0;
213+ for (;; ++i) {
214+ if (i >= arrTest.length) {
215+ break;
216+ }
217+
218+ arrTest[i] = arrTest[i] + 1;
219+ }
220+ return JSONStringify(arrTest);`
221+ ) ;
222+
223+ // Execute
224+ const result = util . executeLua ( lua ) ;
225+
226+ // Assert
227+ Expect ( result ) . toBe ( JSON . stringify ( expected ) ) ;
228+ }
229+
230+ @TestCase ( [ 0 , 1 , 2 , 3 ] , [ 1 , 2 , 3 , 4 ] )
231+ @Test ( "forNoPostExpression" )
232+ public forNoPostExpression ( inp : number [ ] , expected : number [ ] ) : void {
233+ // Transpile
234+ const lua = util . transpileString (
235+ `let arrTest = ${ JSON . stringify ( inp ) } ;
236+ let i = 0;
237+ for (;;) {
238+ if (i >= arrTest.length) {
239+ break;
240+ }
241+
242+ arrTest[i] = arrTest[i] + 1;
243+
244+ i++;
245+ }
246+ return JSONStringify(arrTest);`
247+ ) ;
248+
249+ // Execute
250+ const result = util . executeLua ( lua ) ;
251+
252+ // Assert
253+ Expect ( result ) . toBe ( JSON . stringify ( expected ) ) ;
254+ }
255+
186256 @TestCase ( [ 0 , 1 , 2 , 3 ] , [ 1 , 2 , 3 , 4 ] , "let i = 0; i < arrTest.length; i++" )
187257 @TestCase ( [ 0 , 1 , 2 , 3 ] , [ 1 , 2 , 3 , 4 ] , "let i = 0; i <= arrTest.length - 1; i++" )
188258 @TestCase ( [ 0 , 1 , 2 , 3 ] , [ 1 , 2 , 3 , 4 ] , "let i = 0; arrTest.length > i; i++" )
0 commit comments