update readme (#21797)
[mono-project.git] / mono / tests / struct.cs
blob7e8cf2d56c7a28b686299ae1978a7052aef3d4d9
1 using System;
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;
11 public static Point get_zerop () {
12 Point p = new Point (0, 0);
13 p.z = 0;
14 return p;
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;
27 public class test {
28 public static int Main () {
29 Point p = new Point (10, 20);
30 Point c = p;
31 Point zp;
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;
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;
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;
65 return 0;