Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / tests / struct.cs
1 using System;
2
3 struct Point 
4
5   public int x, y, z; 
6   public Point(int x, int y) { 
7         this.x = x; 
8         this.y = y;
9         this.z = 5;
10   }
11   public static Point get_zerop () {
12                 Point p = new Point (0, 0);
13                 p.z = 0;
14                 return p;
15   }
16   public static int struct_param (Point p) {
17                 if (p.x != p.y || p.y != p.z || p.z != 0)
18                         return 1;
19                 /* should modify the local copy */
20                 p.x = 1;
21                 p.y = 2;
22                 p.z = 3;
23                 return 0;
24   }
25
26
27 public class test {
28         public static int Main () {
29                 Point p = new Point (10, 20);
30                 Point c = p;
31                 Point zp;
32                 
33                 if (c.x != 10)
34                         return 1;
35                 if (c.y != 20)
36                         return 2;
37                 if (c.z != 5)
38                         return 3;
39                 if (p.x != 10)
40                         return 4;
41                 if (p.y != 20)
42                         return 5;
43                 if (p.z != 5)
44                         return 6;
45                 p.z = 7;
46                 if (p.z != 7)
47                         return 7;
48                 if (c.x != 10)
49                         return 8;
50
51                 zp = Point.get_zerop ();
52                 if (zp.x != zp.y || zp.y != zp.z || zp.z != 0)
53                         return 9;
54                 if (Point.struct_param (zp) != 0)
55                         return 10;
56                 if (zp.x != zp.y || zp.y != zp.z || zp.z != 0)
57                         return 11;
58
59                 // Test that the object is properly unboxed when called through
60                 // the reflection interface
61                 object o = Activator.CreateInstance (typeof (Point), new object [] { 1, 2 });
62                 if (!(o is Point))
63                         return 12;
64
65                 return 0;
66         }
67 }