In class/Microsoft.Build.Tasks/Microsoft.Build.Tasks:
[mcs.git] / tests / test-312.cs
blob37f366f02f8de001bc6483f4060a5159d9da7df7
1 using System;
3 struct PointF {
4 public float fa, fb;
6 public PointF (float a, float b)
8 fa = a;
9 fb = b;
10 Console.WriteLine ("PointF created {0} and {1}", fa, fb);
14 struct Point {
15 int ia, ib;
17 public static implicit operator PointF (Point pt)
19 return new PointF (pt.ia, pt.ib);
22 public Point (int a, int b)
24 Console.WriteLine ("Initialized with {0} and {1}", a, b);
25 ia = a;
26 ib = b;
30 class X {
31 static bool ok = false;
32 PointF field;
34 static bool Method (PointF f)
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;
42 static bool Call_constructor_and_implicit ()
44 ok = false;
45 return Method (new Point (100, 200));
49 static bool Init_with_implicit_conv ()
51 PointF p = new Point (1, 100);
52 if (p.fa == 1 && p.fb == 100)
53 return true;
54 return false;
57 static bool Init_ValueType ()
59 Point p = new Point (100, 200);
60 return Method (p);
63 static bool InstanceAssignTest ()
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;
72 static int T ()
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;
86 static int Main ()
88 int t = T ();
89 if (t != 0)
90 Console.WriteLine ("Failed on test: " + t);
91 Console.WriteLine ("Succeed");
92 return t;