2008-08-31 Zoltan Varga <vargaz@gmail.com>
[mcs.git] / tests / test-22.cs
blob2e662494ddde01ae39abf3dd7d5cf37ba99fcdb0
1 //
2 // This test excercises invocations of methods in structures.
3 //
4 // Unlike classes, we can not just leave the result of a computed
5 // structure in the IL stack as a result. The reason is that the
6 // result is the whole structure, not a pointer to it.
7 //
8 // This program excercises invocations to methods on structures
9 //
11 struct T {
12 public int a, b;
15 struct S {
16 T t;
18 public T GetT ()
20 return t;
23 public void Init ()
25 t.a = 1;
26 t.b = 2;
30 class M {
31 static int Main ()
33 S s = new S ();
35 s.Init ();
37 if (s.GetT ().a != 1)
38 return 1;
40 if (s.GetT ().b != 2)
41 return 2;
43 return 0;