@@ -788,6 +788,33 @@ test.each([
788788 util . testExpression ( literal ) . expectToHaveNoDiagnostics ( ) ;
789789} ) ;
790790
791+ describe ( "array.fill" , ( ) => {
792+ test . each ( [ "[]" , "[1]" , "[1,2,3,4]" ] ) ( "Fills full length of array without other parameters (%p)" , arr => {
793+ util . testExpression `${ arr } .fill(5)` . expectToMatchJsResult ( ) ;
794+ } ) ;
795+
796+ test . each ( [ "[1,2,3]" , "[1,2,3,4,5,6]" ] ) ( "Fills starting from start parameter (%p)" , arr => {
797+ util . testExpression `${ arr } .fill(5, 3)` . expectToMatchJsResult ( ) ;
798+ } ) ;
799+
800+ test ( "handles negative start parameter" , ( ) => {
801+ util . testExpression `[1,2,3,4,5,6,7].fill(8, -3)` . expectToMatchJsResult ( ) ;
802+ } ) ;
803+
804+ test ( "handles negative end parameter" , ( ) => {
805+ util . testExpression `[1,2,3,4,5,6,7].fill(8, -5, -2)` . expectToMatchJsResult ( ) ;
806+ } ) ;
807+
808+ test ( "Fills starting from start parameter, up to ending parameter" , ( ) => {
809+ util . testExpression `[1,2,3,4,5,6,7,8].fill(5, 2, 6)` . expectToMatchJsResult ( ) ;
810+ } ) ;
811+
812+ // NOTE: This is different from the default ECMAScript specification for the behavior, but for Lua this is much more useful
813+ test ( "Extends size of the array if ending size is larger than array" , ( ) => {
814+ util . testExpression `[1,2,3].fill(5, 0, 6)` . expectToEqual ( [ 5 , 5 , 5 , 5 , 5 , 5 ] ) ;
815+ } ) ;
816+ } ) ;
817+
791818// Issue #1218: https://github.com/TypeScriptToLua/TypeScriptToLua/issues/1218
792819test . each ( [ "[1, 2, 3]" , "undefined" ] ) ( "prototype call on nullable array (%p)" , value => {
793820 util . testFunction `
0 commit comments