@@ -3,9 +3,8 @@ import { Expect, Test, TestCase } from "alsatian";
33import * as util from "../src/util" ;
44
55export class OverloadTests {
6-
7- @Test ( "overload1" )
8- public overload1 ( ) {
6+ @Test ( "overload function1" )
7+ public overloadFunction1 ( ) {
98 const lua = util . transpileString (
109 `function abc(def: number): string;
1110 function abc(def: string): string;
@@ -23,8 +22,8 @@ export class OverloadTests {
2322 Expect ( result ) . toBe ( "jkl9" ) ;
2423 }
2524
26- @Test ( "overload2 " )
27- public overload2 ( ) {
25+ @Test ( "overload function2 " )
26+ public overloadFunction2 ( ) {
2827 const lua = util . transpileString (
2928 `function abc(def: number): string;
3029 function abc(def: string): string;
@@ -41,4 +40,46 @@ export class OverloadTests {
4140
4241 Expect ( result ) . toBe ( "ghj" ) ;
4342 }
43+
44+ @Test ( "overload method1" )
45+ public overloadMethod1 ( ) {
46+ const lua = util . transpileString (
47+ `class myclass {
48+ static abc(def: number): string;
49+ static abc(def: string): string;
50+ static abc(def: number | string): string {
51+ if (typeof def == "number") {
52+ return "jkl" + (def * 3);
53+ } else {
54+ return def;
55+ }
56+ }
57+ }
58+ return myclass.abc(3);` ) ;
59+
60+ const result = util . executeLua ( lua ) ;
61+
62+ Expect ( result ) . toBe ( "jkl9" ) ;
63+ }
64+
65+ @Test ( "overload method2" )
66+ public overloadMethod2 ( ) {
67+ const lua = util . transpileString (
68+ `class myclass {
69+ static abc(def: number): string;
70+ static abc(def: string): string;
71+ static abc(def: number | string): string {
72+ if (typeof def == "number") {
73+ return "jkl" + (def * 3);
74+ } else {
75+ return def;
76+ }
77+ }
78+ }
79+ return myclass.abc("ghj");` ) ;
80+
81+ const result = util . executeLua ( lua ) ;
82+
83+ Expect ( result ) . toBe ( "ghj" ) ;
84+ }
4485}
0 commit comments