[mcs] C#7 tuples var deconstruct
[mono.git] / mcs / tests / test-tuple-03.cs
1 using System;
2 using System.Linq.Expressions;
3
4 class TupleDeconstruct
5 {
6         static int s_xx;
7         static long s_yy;
8
9         public static int Main ()
10         {
11                 var (xx, yy) = (1, 2);
12                 if (xx != 1)
13                         return 1;
14
15                 if (yy != 2)
16                         return 2;
17
18                 int x, y;
19                 (x, y) = (1, 2);
20                 if (x != 1)
21                         return 3;
22
23                 if (y != 2)
24                         return 4;
25
26                 (s_xx, s_yy) = Test3 ();
27                 if (s_xx != 1)
28                         return 5;
29
30                 if (s_yy != 3)
31                         return 6;
32
33 //              var cwd = new ClassWithDeconstruct ();
34 //              var (m1, m2) = cwd;
35
36 //              (string, string) ss = cwd; // Error
37
38                 return 0;
39         }
40
41         static void Test2 ()
42         {
43                 var c = new C ();
44                 (c.Prop1, c.Prop2) = (1, 2);
45         }
46
47         static (int, long) Test3 ()
48         {
49                 return (1, 3);
50         }
51
52         static void TestCustom ()
53         {
54                 return;
55         }
56 }
57
58 class ClassWithDeconstruct
59 {
60         public void Deconstruct (out string f, out string s)
61         {
62                 f = "a";
63                 s = "z";
64         }
65 }
66
67 class C
68 {
69         public int Prop1 { get; set; }
70         public int Prop2 { get; set; }
71 }