@@ -172,6 +172,35 @@ export class LuaLibArrayTests {
172172 }
173173 }
174174
175+ @TestCase ( [ ] , [ ] )
176+ @TestCase ( [ 1 , 2 , 3 ] , [ ] )
177+ @TestCase ( [ 1 , 2 , 3 ] , [ 4 ] )
178+ @TestCase ( [ 1 , 2 , 3 ] , [ 4 , 5 ] )
179+ @TestCase ( [ 1 , 2 , 3 ] , [ 4 , 5 ] )
180+ @TestCase ( [ 1 , 2 , 3 ] , 4 , [ 5 ] )
181+ @TestCase ( [ 1 , 2 , 3 ] , 4 , [ 5 , 6 ] )
182+ @TestCase ( [ 1 , 2 , 3 ] , 4 , [ 5 , 6 ] , 7 )
183+ @TestCase ( [ 1 , 2 , 3 ] , "test" , [ 5 , 6 ] , 7 , [ "test1" , "test2" ] )
184+ @TestCase ( [ 1 , 2 , "test" ] , "test" , [ "test1" , "test2" ] )
185+ @Test ( "array.concat" )
186+ public concat < T > ( arr : T [ ] , ...args : T [ ] ) {
187+ const argStr = args . map ( arg => JSON . stringify ( arg ) ) . join ( "," ) ;
188+ console . log ( argStr ) ;
189+ console . log ( "\n" ) ;
190+ // Transpile
191+ const lua = util . transpileString (
192+ `let concatTestTable = ${ JSON . stringify ( arr ) } ;
193+ return JSONStringify(concatTestTable.concat(${ argStr } ));`
194+ ) ;
195+
196+ // Execute
197+ const result = util . executeLua ( lua ) ;
198+
199+ // Assert
200+ const concatArr = arr . concat ( ...args ) ;
201+ Expect ( result ) . toBe ( JSON . stringify ( concatArr ) ) ;
202+ }
203+
175204 @TestCase ( [ ] , "" )
176205 @TestCase ( [ "test1" ] , "test1" )
177206 @TestCase ( [ "test1" , "test2" ] , "test1,test2" )
@@ -308,7 +337,7 @@ export class LuaLibArrayTests {
308337 // Assert
309338 Expect ( result ) . toBe ( expected ) ;
310339 }
311-
340+
312341 @TestCase ( "true" , 11 )
313342 @TestCase ( "false" , 13 )
314343 @TestCase ( "a < 4" , 13 )
0 commit comments