@@ -4,7 +4,7 @@ import * as util from "../src/util";
44
55export class OverloadTests {
66 @Test ( "overload function1" )
7- public overloadFunction1 ( ) {
7+ public overloadFunction1 ( ) : void {
88 const lua = util . transpileString (
99 `function abc(def: number): string;
1010 function abc(def: string): string;
@@ -23,7 +23,7 @@ export class OverloadTests {
2323 }
2424
2525 @Test ( "overload function2" )
26- public overloadFunction2 ( ) {
26+ public overloadFunction2 ( ) : void {
2727 const lua = util . transpileString (
2828 `function abc(def: number): string;
2929 function abc(def: string): string;
@@ -42,7 +42,7 @@ export class OverloadTests {
4242 }
4343
4444 @Test ( "overload method1" )
45- public overloadMethod1 ( ) {
45+ public overloadMethod1 ( ) : void {
4646 const lua = util . transpileString (
4747 `class myclass {
4848 static abc(def: number): string;
@@ -63,7 +63,7 @@ export class OverloadTests {
6363 }
6464
6565 @Test ( "overload method2" )
66- public overloadMethod2 ( ) {
66+ public overloadMethod2 ( ) : void {
6767 const lua = util . transpileString (
6868 `class myclass {
6969 static abc(def: number): string;
@@ -82,4 +82,54 @@ export class OverloadTests {
8282
8383 Expect ( result ) . toBe ( "ghj" ) ;
8484 }
85+
86+ @Test ( "constructor1" )
87+ public constructor1 ( ) : void {
88+ const lua = util . transpileString (
89+ `class myclass {
90+ num: number;
91+ str: string;
92+
93+ constructor(def: number): string;
94+ constructor(def: string): string;
95+ constructor(def: number | string): string {
96+ if (typeof def == "number") {
97+ this.num = def;
98+ } else {
99+ this.str = def;
100+ }
101+ }
102+ }
103+ const inst = new myclass(3);
104+ return inst.num` ) ;
105+
106+ const result = util . executeLua ( lua ) ;
107+
108+ Expect ( result ) . toBe ( 3 ) ;
109+ }
110+
111+ @Test ( "constructor2" )
112+ public constructor2 ( ) : void {
113+ const lua = util . transpileString (
114+ `class myclass {
115+ num: number;
116+ str: string;
117+
118+ constructor(def: number): string;
119+ constructor(def: string): string;
120+ constructor(def: number | string): string {
121+ if (typeof def == "number") {
122+ this.num = def;
123+ } else {
124+ this.str = def;
125+ }
126+ }
127+ }
128+ const inst = new myclass("ghj");
129+ return inst.str` ) ;
130+
131+ const result = util . executeLua ( lua ) ;
132+
133+ Expect ( result ) . toBe ( "ghj" ) ;
134+ }
85135}
0 commit comments