@@ -98,6 +98,9 @@ export class LuaLoopTests {
9898 }
9999
100100 @TestCase ( [ 0 , 1 , 2 , 3 ] , [ 1 , 2 , 3 , 4 ] , "let i = 0; i < arrTest.length; i++" )
101+ @TestCase ( [ 0 , 1 , 2 , 3 ] , [ 1 , 2 , 3 , 4 ] , "let i = 0; i <= arrTest.length - 1; i++" )
102+ @TestCase ( [ 0 , 1 , 2 , 3 ] , [ 1 , 2 , 3 , 4 ] , "let i = 0; arrTest.length > i; i++" )
103+ @TestCase ( [ 0 , 1 , 2 , 3 ] , [ 1 , 2 , 3 , 4 ] , "let i = 0; arrTest.length - 1 >= i; i++" )
101104 @TestCase ( [ 0 , 1 , 2 , 3 ] , [ 1 , 1 , 3 , 3 ] , "let i = 0; i < arrTest.length; i += 2" )
102105 @TestCase ( [ 0 , 1 , 2 , 3 ] , [ 1 , 2 , 3 , 4 ] , "let i = arrTest.length - 1; i <= 0; i--" )
103106 @TestCase ( [ 0 , 1 , 2 , 3 ] , [ 0 , 2 , 2 , 4 ] , "let i = arrTest.length - 1; i <= 0; i -= 2" )
@@ -135,18 +138,26 @@ export class LuaLoopTests {
135138 } ) . toThrowError ( Error , "Unsupported for-loop increment step: BinaryExpression" )
136139 }
137140
141+ @TestCase ( "let i = 0; i + 3; i++" )
142+ @TestCase ( "let i = 0; 3 + i; i++" )
143+ @TestCase ( "let i = 0; i - 3; i++" )
144+ @TestCase ( "let i = 0; i * 3; i++" )
145+ @TestCase ( "let i = 0; i / 3; i++" )
146+ @TestCase ( "let i = 0; i &= 3; i++" )
147+ @TestCase ( "let i = 0; i < 3; !i" )
148+ @TestCase ( "let i = 0; i < 3; i as string" )
138149 @Test ( "forconditionThrow" )
139- public forconditionThrow ( inp : number [ ] , expected : number [ ] , header : string ) {
150+ public forconditionThrow ( header : string ) {
140151 // Transpile & Assert
141152 Expect ( ( ) => {
142153 let lua = util . transpileString (
143- `for (let i = arrTest.length - 1; i; i-- {
154+ `for (${ header } ) {
144155 }`
145156 ) ;
146157
147158 // Execute
148159 let result = util . executeLua ( lua ) ;
149- } ) . toThrowError ( Error , "Unsupported for-loop condition type: Identifier" )
160+ } ) . toThrow ( ) ;
150161 }
151162
152163 @TestCase ( { [ 'test1' ] : 0 , [ 'test2' ] : 1 , [ 'test3' ] : 2 } , { [ 'test1' ] : 1 , [ 'test2' ] : 2 , [ 'test3' ] : 3 } )
0 commit comments