@@ -159,24 +159,31 @@ test("Class static dot method with parameter", () => {
159159 ` . expectToMatchJsResult ( ) ;
160160} ) ;
161161
162- test ( "Function bind" , ( ) => {
162+ const functionTypeDeclarations = [
163+ [ "arrow" , ": (...args: any) => any" ] ,
164+ [ "call signature" , ": { (...args: any): any; }" ] ,
165+ [ "generic" , ": Function" ] ,
166+ [ "inferred" , "" ] ,
167+ ] ;
168+
169+ test . each ( functionTypeDeclarations ) ( "Function bind (%s)" , ( _ , type ) => {
163170 util . testFunction `
164- const abc = function (this: { a: number }, a: string, b: string) { return this.a + a + b; }
171+ const abc${ type } = function (this: { a: number }, a: string, b: string) { return this.a + a + b; }
165172 return abc.bind({ a: 4 }, "b")("c");
166173 ` . expectToMatchJsResult ( ) ;
167174} ) ;
168175
169- test ( "Function apply" , ( ) => {
176+ test . each ( functionTypeDeclarations ) ( "Function apply (%s) " , ( _ , type ) => {
170177 util . testFunction `
171- const abc = function (this: { a: number }, a: string) { return this.a + a; }
178+ const abc${ type } = function (this: { a: number }, a: string) { return this.a + a; }
172179 return abc.apply({ a: 4 }, ["b"]);
173180 ` . expectToMatchJsResult ( ) ;
174181} ) ;
175182
176183// Fix #1226: https://github.com/TypeScriptToLua/TypeScriptToLua/issues/1226
177- test ( "function apply without arguments should not lead to exception" , ( ) => {
184+ test . each ( functionTypeDeclarations ) ( "function apply without arguments should not lead to exception (%s) " , ( _ , type ) => {
178185 util . testFunction `
179- const f = function (this: number) { return this + 3; }
186+ const f${ type } = function (this: number) { return this + 3; }
180187 return f.apply(4);
181188 ` . expectToMatchJsResult ( ) ;
182189} ) ;
@@ -193,9 +200,9 @@ test.each(["() => 4", "undefined"])("prototype call on nullable function (%p)",
193200 . expectToMatchJsResult ( ) ;
194201} ) ;
195202
196- test ( "Function call" , ( ) => {
203+ test . each ( functionTypeDeclarations ) ( "Function call (%s) " , ( _ , type ) => {
197204 util . testFunction `
198- const abc = function (this: { a: number }, a: string) { return this.a + a; }
205+ const abc${ type } = function (this: { a: number }, a: string) { return this.a + a; }
199206 return abc.call({ a: 4 }, "b");
200207 ` . expectToMatchJsResult ( ) ;
201208} ) ;
0 commit comments