@@ -22,3 +22,37 @@ test('Default constructor', async () => {
22
22
let test_interface : bacardi . TestInterface = new bacardi . TestInterface ( ) ;
23
23
expect ( test_interface instanceof bacardi . TestInterface ) . toBe ( true ) ;
24
24
} ) ;
25
+
26
+ test ( 'Calling undefined constructor should throw error' , async ( ) => {
27
+ expect ( ( ) => {
28
+ // There is no TestInterface(string) constructor.
29
+ new bacardi . TestInterface ( 'Wrong argument' ) ;
30
+ } ) . toThrowError ( ) ;
31
+
32
+ expect ( ( ) => {
33
+ // There is no TestInterface(number, number, number) constructor.
34
+ new bacardi . TestInterface ( 1 , 2 , 3 ) ;
35
+ } ) . toThrowError ( ) ;
36
+ } ) ;
37
+
38
+ test ( 'When creating two objects, should be differnt instances' , async ( ) => {
39
+ let instance1 : bacardi . TestInterface = new bacardi . TestInterface ( ) ;
40
+ let instance2 : bacardi . TestInterface = new bacardi . TestInterface ( ) ;
41
+ expect ( instance1 !== instance2 ) . toBe ( true ) ;
42
+ } ) ;
43
+
44
+ test ( 'Test for constructor overloading' , async ( ) => {
45
+ let constructor1 = new bacardi . TestInterface ( ) ;
46
+ expect ( constructor1 . getCalledConstructorInfo ( ) ) . toBe ( 'Constructor()' ) ;
47
+
48
+ let constructor2 = new bacardi . TestInterface ( 1 ) ;
49
+ expect ( constructor2 . getCalledConstructorInfo ( ) ) . toBe ( 'Constructor(long)' ) ;
50
+
51
+ let constructor3 = new bacardi . TestInterface ( 2 , 3 ) ;
52
+ expect ( constructor3 . getCalledConstructorInfo ( ) )
53
+ . toBe ( 'Constructor(long, long)' ) ;
54
+
55
+ let constructor4 = new bacardi . TestInterface ( 'hello' , 'world' ) ;
56
+ expect ( constructor4 . getCalledConstructorInfo ( ) )
57
+ . toBe ( 'Constructor(string, string)' ) ;
58
+ } ) ;
0 commit comments