Merge pull request #5675 from mono/glib-debug-symbols
[mono.git] / mcs / tests / test-312.cs
1 using System;
2
3 struct PointF {
4         public float fa, fb;
5         
6         public PointF (float a, float b)
7         {
8                 fa = a;
9                 fb = b;
10                 Console.WriteLine ("PointF created {0} and {1}", fa, fb);
11         }
12 }
13
14 struct Point {
15         int ia, ib;
16         
17         public static implicit operator PointF (Point pt)
18         {
19                 return new PointF (pt.ia, pt.ib);
20         }
21
22         public Point (int a, int b)
23         {
24                 Console.WriteLine ("Initialized with {0} and {1}", a, b);
25                 ia = a;
26                 ib = b;
27         }
28 }
29
30 class X {
31         static bool ok = false;
32         PointF field;
33         
34         static bool Method (PointF f)
35         {
36                 Console.WriteLine ("Method with PointF arg: {0} {1}", f.fa, f.fb);
37                 if (f.fa != 100 || f.fb != 200)
38                         return false;
39                 return true;
40         }
41         
42         static bool Call_constructor_and_implicit ()
43         {
44                 ok = false;
45                 return Method (new Point (100, 200));
46         }
47
48
49         static bool Init_with_implicit_conv ()
50         {
51                 PointF p = new Point (1, 100);
52                 if (p.fa == 1 && p.fb == 100)
53                         return true;
54                 return false;
55         }
56
57         static bool Init_ValueType ()
58         {
59                 Point p = new Point (100, 200);
60                 return Method (p);
61         }
62         
63         static bool InstanceAssignTest ()
64         {
65                 X x = new X ();
66                 x.field = new Point (100, 200);
67                 if (x.field.fa != 100 || x.field.fb != 200)
68                         return false;
69                 return true;
70         }
71         
72         static int T ()
73         {
74                 
75                 if (!Init_with_implicit_conv ())
76                         return 100;
77                 if (!Call_constructor_and_implicit ())
78                         return 101;
79                 if (!Init_ValueType ())
80                         return 102;
81                 if (!InstanceAssignTest ())
82                         return 103;
83                 return 0;
84         }
85
86         public static int Main ()
87         {
88                 int t = T ();
89                 if (t != 0)
90                         Console.WriteLine ("Failed on test: " + t);
91                 Console.WriteLine ("Succeed");
92                 return t;
93         }
94         
95 }