Convert dynamic assignment in checked context when set
[mono.git] / mcs / tests / dtest-033.cs
1 using System;
2
3 public class Test
4 {
5         byte Prop {
6                 get { return 4; }
7                 set { }
8         }
9
10         byte this [int arg] {
11                 get { return 2; }
12                 set { }
13         }
14
15         public static int Main ()
16         {
17                 dynamic v = 'a';
18                 dynamic a = new Test ();
19
20                 string s = "-sdfas";
21                 
22                 // dynamic compound assignment with different result type
23                 v += s;
24
25                 if (v != "a-sdfas")
26                         return 1;
27                 
28                 dynamic d2 = null;
29                 d2 += "a";
30                 if (d2 != "a")
31                         return 2;
32
33                 byte b = 4;
34                 a.Prop *= b;
35                 a[4] ^= b;
36                 
37                 dynamic d = 1;
38                 b = byte.MaxValue;
39                 try {
40                         checked {
41                                 b += d;
42                                 return 1;
43                         }
44                 } catch (OverflowException) {
45                 }
46                 
47                 b += d;
48
49                 return 0;
50         }
51 }