@@ -325,7 +325,7 @@ test.each([
325325 { array : [ 0 , 2 , 4 , 8 ] , predicate : "false" } ,
326326] ) ( "array.find (%p)" , ( { array, predicate } ) => {
327327 util . testFunction `
328- const array = ${ util . formatCode ( array ) } ;
328+ const array: number[] = ${ util . formatCode ( array ) } ;
329329 return array.find((elem, index, arr) => ${ predicate } && arr[index] === elem);
330330 ` . expectToMatchJsResult ( ) ;
331331} ) ;
@@ -337,7 +337,7 @@ test.each([
337337 { array : [ 0 , 2 , 4 , 8 ] , searchElement : 8 } ,
338338] ) ( "array.findIndex (%p)" , ( { array, searchElement } ) => {
339339 util . testFunction `
340- const array = ${ util . formatCode ( array ) } ;
340+ const array: number[] = ${ util . formatCode ( array ) } ;
341341 return array.findIndex((elem, index, arr) => elem === ${ searchElement } && arr[index] === elem);
342342 ` . expectToMatchJsResult ( ) ;
343343} ) ;
@@ -422,7 +422,7 @@ test.each([
422422 { array : [ 0 , 1 , 2 , 3 ] , start : 1 , deleteCount : null } ,
423423] ) ( "array.splice (%p)" , ( { array, start, deleteCount, newElements = [ ] } ) => {
424424 util . testFunction `
425- const array = ${ util . formatCode ( array ) } ;
425+ const array: number[] = ${ util . formatCode ( array ) } ;
426426 array.splice(${ util . formatCode ( start , deleteCount , ...newElements ) } );
427427 return array;
428428 ` . expectToMatchJsResult ( ) ;
@@ -510,8 +510,11 @@ test("array.join without separator argument", () => {
510510 util . testExpression `["test1", "test2"].join()` . expectToMatchJsResult ( ) ;
511511} ) ;
512512
513+ test ( "array.indexOf empty array" , ( ) => {
514+ util . testExpression `([] as string[]).indexOf("test1")` . expectToMatchJsResult ( ) ;
515+ } ) ;
516+
513517test . each ( [
514- { array : [ ] , args : [ "test1" ] } ,
515518 { array : [ "test1" ] , args : [ "test1" ] } ,
516519 { array : [ "test1" , "test2" ] , args : [ "test2" ] } ,
517520 { array : [ "test1" , "test2" , "test3" ] , args : [ "test3" , 1 ] } ,
@@ -571,7 +574,7 @@ test.each([{ array: [1, 2, 3] }, { array: [1, 2, 3, 4] }, { array: [1] }, { arra
571574 "array.reverse (%p)" ,
572575 ( { array } ) => {
573576 util . testFunction `
574- const array = ${ util . formatCode ( array ) } ;
577+ const array: number[] = ${ util . formatCode ( array ) } ;
575578 array.reverse();
576579 return array;
577580 ` . expectToMatchJsResult ( ) ;
@@ -580,7 +583,7 @@ test.each([{ array: [1, 2, 3] }, { array: [1, 2, 3, 4] }, { array: [1] }, { arra
580583
581584test . each ( [ { array : [ 1 , 2 , 3 ] } , { array : [ 1 ] } , { array : [ ] } ] ) ( "array.shift (%p)" , ( { array } ) => {
582585 util . testFunction `
583- const array = ${ util . formatCode ( array ) } ;
586+ const array: number[] = ${ util . formatCode ( array ) } ;
584587 const value = array.shift();
585588 return { array, value };
586589 ` . expectToMatchJsResult ( ) ;
@@ -593,15 +596,15 @@ test.each([
593596 { array : [ ] , args : [ 1 ] } ,
594597] ) ( "array.unshift (%p)" , ( { array, args } ) => {
595598 util . testFunction `
596- const array = ${ util . formatCode ( array ) } ;
599+ const array: number[] = ${ util . formatCode ( array ) } ;
597600 const value = array.unshift(${ util . formatCode ( ...args ) } );
598601 return { array, value };
599602 ` . expectToMatchJsResult ( ) ;
600603} ) ;
601604
602605test . each ( [ { array : [ 4 , 5 , 3 , 2 , 1 ] } , { array : [ 1 ] } , { array : [ ] } ] ) ( "array.sort (%p)" , ( { array } ) => {
603606 util . testFunctionTemplate `
604- const array = ${ array } ;
607+ const array: number[] = ${ array } ;
605608 array.sort();
606609 return array;
607610 ` . expectToMatchJsResult ( ) ;
@@ -659,7 +662,7 @@ describe.each(["reduce", "reduceRight"])("array.%s", reduce => {
659662 } ) ;
660663
661664 test ( "empty no initial" , ( ) => {
662- util . testExpression `[] .${ reduce } (() => {})` . expectToMatchJsResult ( true ) ;
665+ util . testExpression `([] as any[]) .${ reduce } (() => {})` . expectToMatchJsResult ( true ) ;
663666 } ) ;
664667
665668 test ( "undefined returning callback" , ( ) => {
@@ -675,7 +678,7 @@ test.each([{ array: [] }, { array: ["a", "b", "c"] }, { array: [{ foo: "foo" },
675678 "array.entries (%p)" ,
676679 ( { array } ) => {
677680 util . testFunction `
678- const array = ${ util . formatCode ( array ) } ;
681+ const array: any[] = ${ util . formatCode ( array ) } ;
679682 const result = [];
680683 for (const [i, v] of array.entries()) {
681684 result.push([i, v]);
@@ -800,7 +803,7 @@ test.each([
800803} ) ;
801804
802805describe ( "array.fill" , ( ) => {
803- test . each ( [ "[] " , "[1]" , "[1,2,3,4]" ] ) ( "Fills full length of array without other parameters (%p)" , arr => {
806+ test . each ( [ "([] as number[]) " , "[1]" , "[1,2,3,4]" ] ) ( "Fills full length of array without other parameters (%p)" , arr => {
804807 util . testExpression `${ arr } .fill(5)` . expectToMatchJsResult ( ) ;
805808 } ) ;
806809
0 commit comments