@@ -246,9 +246,25 @@ test("array.forEach (%p)", () => {
246246 ` . expectToMatchJsResult ( ) ;
247247} ) ;
248248
249+ test . each ( [
250+ { array : [ ] , predicate : "elem > 3" } ,
251+ { array : [ 0 , 2 , 4 , 8 ] , predicate : "elem > 10" } ,
252+ { array : [ 0 , 2 , 4 , 8 ] , predicate : "elem > 7" } ,
253+ { array : [ 0 , 2 , 4 , 8 ] , predicate : "elem == 0" } ,
254+ { array : [ 0 , 2 , 4 , 8 ] , predicate : "elem > 7" } ,
255+ { array : [ 0 , 2 , 4 , 8 ] , predicate : "true" } ,
256+ { array : [ 0 , 2 , 4 , 8 ] , predicate : "false" } ,
257+ ] ) ( "array.find (%p)" , ( { array, predicate } ) => {
258+ util . testFunction `
259+ const array = ${ util . valueToString ( array ) } ;
260+ return array.find((elem, index, arr) => ${ predicate } && arr[index] === elem);
261+ ` . expectToMatchJsResult ( ) ;
262+ } ) ;
263+
249264test . each ( [
250265 { array : [ ] , searchElement : 3 } ,
251266 { array : [ 0 , 2 , 4 , 8 ] , searchElement : 10 } ,
267+ { array : [ 0 , 2 , 4 , 8 ] , searchElement : 0 } ,
252268 { array : [ 0 , 2 , 4 , 8 ] , searchElement : 8 } ,
253269] ) ( "array.findIndex (%p)" , ( { array, searchElement } ) => {
254270 util . testFunction `
@@ -486,6 +502,22 @@ test.each<[[(total: number, currentItem: number, index: number, array: number[])
486502 util . testExpression `[1, 3, 5, 7].reduce(${ util . valuesToString ( args ) } )` . expectToMatchJsResult ( ) ;
487503} ) ;
488504
505+ test ( "array.reduce empty undefined initial" , ( ) => {
506+ util . testExpression `[].reduce(() => {}, undefined)` . expectToMatchJsResult ( ) ;
507+ } ) ;
508+
509+ test ( "array.reduce empty no initial" , ( ) => {
510+ util . testExpression `[].reduce(() => {})` . expectToMatchJsResult ( true ) ;
511+ } ) ;
512+
513+ test ( "array.reduce undefined returning callback" , ( ) => {
514+ util . testFunction `
515+ const calls: Array<{ a: void, b: string }> = [];
516+ ["a", "b"].reduce<void>((a, b) => { calls.push({ a, b }) }, undefined);
517+ return calls;
518+ ` . expectToMatchJsResult ( ) ;
519+ } ) ;
520+
489521const genericChecks = [
490522 "function generic<T extends number[]>(array: T)" ,
491523 "function generic<T extends [...number[]]>(array: T)" ,
0 commit comments