abouttreesummaryrefslogcommitdiff
path: root/test/test2.toc
blob: abd6bc77ea9874eef8ecd6fc27f32402c5d392f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
func puts(str : char*) : void;

namespace N1 {
  func f1() : void {
    puts("Hello\n");
  }
  namespace N2 {
    struct S1 {
      i1 : int;
      i2 : int;
      i3 : int;

      m1(i: int) : int {
        this->i3 = this->i1 * this->i2;

        f1();
        N1::f1();

        return this->i1 + this->i2;
      }
    }

    func f1() : void {
      var s1 : N1::N2::S1;

      s1.m1(123);
    }
  }
}

struct S1<T> {
  t1: T;
  t2: T;

  m1() : T {
    return this->t1 + this->t2;
  }
}

struct S2 {
  abc(): S2 { }
  xyz(): S2 { }
}

func generic1<A>(a1 : A, a2 : A) : A {
  return a1 + a2;
}

func main(argc : int, argv : char**) : int {
  var s1 : N1::N2::S1;
  var s2 : N1::N2::S1;
  var s3 : N1::N2::S1;
  s1.i1 = 123;
  s1.i2 = 456;
  s1.m1(s2.m1(s3.m1(89)));

  N1::N2::f1();

  var s4 : S1<int>;
  s4.t1 = 123;  
  s4.t2 = 456;  
  s4.m1();

  generic1<int>(1, 2);
  generic1<double>(3.4, 5.6);

  var s: S2;
  s.abc().xyz();

  return 0;
}