1
1
import * as util from "../../../util" ;
2
2
import {
3
- anonTestFunctionExpressions ,
3
+ anonArrowFunctionExpressions ,
4
+ anonNonArrowFunctionExpressions ,
4
5
anonTestFunctionType ,
5
6
noSelfTestFunctionExpressions ,
6
7
noSelfTestFunctions ,
@@ -133,10 +134,10 @@ test.each([
133
134
} ) ;
134
135
135
136
test . 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'" ] ] ) ,
138
139
...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 ) => {
140
141
util . testFunction `
141
142
const takesFunction: any = (fn: (this: void, ...args: any[]) => any, ...args: any[]) => {
142
143
return fn(...args);
@@ -147,6 +148,20 @@ test.each([
147
148
. expectToEqual ( "foobar" ) ;
148
149
} ) ;
149
150
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
+
150
165
test . each ( validTestFunctionAssignments ) ( "Valid function return (%p)" , ( testFunction , functionType ) => {
151
166
util . testFunction `
152
167
function returnsFunction(): ${ functionType } {
0 commit comments