11import * as util from "../../../util" ;
22import {
3- anonTestFunctionExpressions ,
3+ anonArrowFunctionExpressions ,
4+ anonNonArrowFunctionExpressions ,
45 anonTestFunctionType ,
56 noSelfTestFunctionExpressions ,
67 noSelfTestFunctions ,
@@ -133,10 +134,10 @@ test.each([
133134} ) ;
134135
135136test . each ( [
136- ...anonTestFunctionExpressions . map ( ( f ) : [ TestFunction , string [ ] ] => [ f , [ "0 " , "'foobar'" ] ] ) ,
137- ...selfTestFunctionExpressions . map ( ( f ) : [ TestFunction , string [ ] ] => [ f , [ "0 " , "'foobar'" ] ] ) ,
137+ ...anonNonArrowFunctionExpressions . map ( ( f ) : [ TestFunction , string [ ] ] => [ f , [ "'context' " , "'foobar'" ] ] ) ,
138+ ...selfTestFunctionExpressions . map ( ( f ) : [ TestFunction , string [ ] ] => [ f , [ "'context' " , "'foobar'" ] ] ) ,
138139 ...noSelfTestFunctionExpressions . map ( ( f ) : [ TestFunction , string [ ] ] => [ f , [ "'foobar'" ] ] ) ,
139- ] ) ( "Valid function expression argument with no signature (%p, %p)" , ( testFunction , args ) => {
140+ ] ) ( "Valid function expression argument with no signature have context (%p, %p)" , ( testFunction , args ) => {
140141 util . testFunction `
141142 const takesFunction: any = (fn: (this: void, ...args: any[]) => any, ...args: any[]) => {
142143 return fn(...args);
@@ -147,6 +148,20 @@ test.each([
147148 . expectToEqual ( "foobar" ) ;
148149} ) ;
149150
151+ test . each ( [ ...anonArrowFunctionExpressions . map ( ( f ) : [ TestFunction , string [ ] ] => [ f , [ "'foobar'" ] ] ) ] ) (
152+ "Valid arrow function expression argument with no signature do not have context (%p, %p)" ,
153+ ( testFunction , args ) => {
154+ util . testFunction `
155+ const takesFunction: any = (fn: (this: void, ...args: any[]) => any, ...args: any[]) => {
156+ return fn(...args);
157+ }
158+ return takesFunction(${ testFunction . value } , ${ args . join ( ", " ) } );
159+ `
160+ . setTsHeader ( testFunction . definition ?? "" )
161+ . expectToEqual ( "foobar" ) ;
162+ }
163+ ) ;
164+
150165test . each ( validTestFunctionAssignments ) ( "Valid function return (%p)" , ( testFunction , functionType ) => {
151166 util . testFunction `
152167 function returnsFunction(): ${ functionType } {
0 commit comments