Debian Codegraph @

src/test/01-Basic/239-ctor-default.ck

raw
1 // verify that default constructor is invoked with or without ()
2
3 // a class
4 class Foo
5 {
6 // a member var
7 int x;
8
9 // default constructor
10 fun void Foo()
11 {
12 5 => x;
13 }
14 }
15
16 // instantiate with and without ()
17 new Foo @=> Foo @ f1;
18 new Foo() @=> Foo @ f2;
19 Foo f3;
20 Foo f4();
21
22 // test
23 if( f1.x == 5 && f2.x == 5 && f3.x == 5 && f4.x == 5 )
24 <<< "success" >>>;