@@ -262,6 +262,38 @@ export class LuaLibArrayTests {
262262 Expect ( result ) . toBe ( JSON . stringify ( [ 0 ] . concat ( inp ) ) ) ;
263263 }
264264
265+ @TestCase ( "[1, 2, 3]" , [ 3 , 2 ] )
266+ @TestCase ( "[1, 2, 3, null]" , [ 3 , 2 ] )
267+ @Test ( "array.pop" )
268+ public arrayPop ( array : string , expected ) {
269+ {
270+ // Transpile
271+ const lua = util . transpileString (
272+ `let testArray = ${ array } ;
273+ let val = testArray.pop();
274+ return val` ) ;
275+
276+ // Execute
277+ const result = util . executeLua ( lua ) ;
278+
279+ // Assert
280+ Expect ( result ) . toBe ( expected [ 0 ] ) ;
281+ }
282+ {
283+ // Transpile
284+ const lua = util . transpileString (
285+ `let testArray = ${ array } ;
286+ testArray.pop();
287+ return testArray.length` ) ;
288+
289+ // Execute
290+ const result = util . executeLua ( lua ) ;
291+
292+ // Assert
293+ Expect ( result ) . toBe ( expected [ 1 ] ) ;
294+ }
295+ }
296+
265297 @TestCase ( "true" , "4" , "5" , 4 )
266298 @TestCase ( "false" , "4" , "5" , 5 )
267299 @TestCase ( "3" , "4" , "5" , 4 )
@@ -276,7 +308,7 @@ export class LuaLibArrayTests {
276308 // Assert
277309 Expect ( result ) . toBe ( expected ) ;
278310 }
279-
311+
280312 @TestCase ( "true" , 11 )
281313 @TestCase ( "false" , 13 )
282314 @TestCase ( "a < 4" , 13 )
0 commit comments