Enhanced test for valuetypes.
[mono.git] / mono / tests / struct.cs
1 struct Point 
2
3   public int x, y, z; 
4   public Point(int x, int y) { 
5         this.x = x; 
6         this.y = y;
7         this.z = 5;
8   }
9   public static Point get_zerop () {
10                 Point p = new Point (0, 0);
11                 p.z = 0;
12                 return p;
13   }
14   public static int struct_param (Point p) {
15                 if (p.x != p.y || p.y != p.z || p.z != 0)
16                         return 1;
17                 /* should modify the local copy */
18                 p.x = 1;
19                 p.y = 2;
20                 p.z = 3;
21                 return 0;
22   }
23
24
25 public class test {
26         public static int Main () {
27                 Point p = new Point (10, 20);
28                 Point c = p;
29                 Point zp;
30                 
31                 if (c.x != 10)
32                         return 1;
33                 if (c.y != 20)
34                         return 2;
35                 if (c.z != 5)
36                         return 3;
37                 if (p.x != 10)
38                         return 4;
39                 if (p.y != 20)
40                         return 5;
41                 if (p.z != 5)
42                         return 6;
43                 p.z = 7;
44                 if (p.z != 7)
45                         return 7;
46                 if (c.x != 10)
47                         return 8;
48
49                 zp = Point.get_zerop ();
50                 if (zp.x != zp.y || zp.y != zp.z || zp.z != 0)
51                         return 9;
52                 if (Point.struct_param (zp) != 0)
53                         return 10;
54                 if (zp.x != zp.y || zp.y != zp.z || zp.z != 0)
55                         return 11;
56                 return 0;
57         }
58 }