~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to contrib/ICSharpCode.Decompiler/Tests/IncrementDecrement.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
ļ»æ// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
 
2
// 
 
3
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
 
4
// software and associated documentation files (the "Software"), to deal in the Software
 
5
// without restriction, including without limitation the rights to use, copy, modify, merge,
 
6
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
 
7
// to whom the Software is furnished to do so, subject to the following conditions:
 
8
// 
 
9
// The above copyright notice and this permission notice shall be included in all copies or
 
10
// substantial portions of the Software.
 
11
// 
 
12
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
 
13
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 
14
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
 
15
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
 
16
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 
17
// DEALINGS IN THE SOFTWARE.
 
18
 
 
19
using System;
 
20
 
 
21
public class IncrementDecrement
 
22
{
 
23
        [Flags]
 
24
        private enum MyEnum
 
25
        {
 
26
                None = 0,
 
27
                One = 1,
 
28
                Two = 2,
 
29
                Four = 4
 
30
        }
 
31
        
 
32
        public class MutableClass
 
33
        {
 
34
                public int Field;
 
35
                
 
36
                public int Property
 
37
                {
 
38
                        get;
 
39
                        set;
 
40
                }
 
41
                
 
42
                public uint this[string name]
 
43
                {
 
44
                        get
 
45
                        {
 
46
                                return 0u;
 
47
                        }
 
48
                        set
 
49
                        {
 
50
                        }
 
51
                }
 
52
        }
 
53
        
 
54
        private IncrementDecrement.MyEnum enumField;
 
55
        public static int StaticField;
 
56
        
 
57
        public static int StaticProperty
 
58
        {
 
59
                get;
 
60
                set;
 
61
        }
 
62
        
 
63
        private IncrementDecrement.MutableClass M()
 
64
        {
 
65
                return new IncrementDecrement.MutableClass();
 
66
        }
 
67
        
 
68
        private int[,] Array()
 
69
        {
 
70
                return null;
 
71
        }
 
72
        
 
73
        private unsafe int* GetPointer()
 
74
        {
 
75
                return null;
 
76
        }
 
77
        
 
78
        public int PreIncrementInAddition(int i, int j)
 
79
        {
 
80
                return i + ++j;
 
81
        }
 
82
        
 
83
        public int PreIncrementArrayElement(int[] array, int pos)
 
84
        {
 
85
                return --array[pos];
 
86
        }
 
87
        
 
88
        public int PreIncrementInstanceField()
 
89
        {
 
90
                return ++this.M().Field;
 
91
        }
 
92
        
 
93
        public int PreIncrementInstanceField2(IncrementDecrement.MutableClass m)
 
94
        {
 
95
                return ++m.Field;
 
96
        }
 
97
        
 
98
        public int PreIncrementInstanceProperty()
 
99
        {
 
100
                return ++this.M().Property;
 
101
        }
 
102
        
 
103
        public int PreIncrementStaticField()
 
104
        {
 
105
                return ++IncrementDecrement.StaticField;
 
106
        }
 
107
        
 
108
        public int PreIncrementStaticProperty()
 
109
        {
 
110
                return ++IncrementDecrement.StaticProperty;
 
111
        }
 
112
        
 
113
//      public uint PreIncrementIndexer(string name)
 
114
//      {
 
115
//              return ++this.M()[name];
 
116
//      }
 
117
        
 
118
        public int PreIncrementByRef(ref int i)
 
119
        {
 
120
                return ++i;
 
121
        }
 
122
        
 
123
        public unsafe int PreIncrementByPointer()
 
124
        {
 
125
                return ++(*this.GetPointer());
 
126
        }
 
127
        
 
128
        public int PreIncrement2DArray()
 
129
        {
 
130
                return ++this.Array()[1, 2];
 
131
        }
 
132
        
 
133
        public int CompoundAssignInstanceField()
 
134
        {
 
135
                return this.M().Field *= 10;
 
136
        }
 
137
        
 
138
        public int CompoundAssignInstanceProperty()
 
139
        {
 
140
                return this.M().Property *= 10;
 
141
        }
 
142
        
 
143
        public int CompoundAssignStaticField()
 
144
        {
 
145
                return IncrementDecrement.StaticField ^= 100;
 
146
        }
 
147
        
 
148
        public int CompoundAssignStaticProperty()
 
149
        {
 
150
                return IncrementDecrement.StaticProperty &= 10;
 
151
        }
 
152
        
 
153
        public int CompoundAssignArrayElement1(int[] array, int pos)
 
154
        {
 
155
                return array[pos] *= 10;
 
156
        }
 
157
        
 
158
        public int CompoundAssignArrayElement2(int[] array)
 
159
        {
 
160
                return array[Environment.TickCount] *= 10;
 
161
        }
 
162
        
 
163
//      public uint CompoundAssignIndexer(string name)
 
164
//      {
 
165
//              return this.M()[name] -= 2;
 
166
//      }
 
167
        
 
168
        public int CompoundAssignIncrement2DArray()
 
169
        {
 
170
                return this.Array()[1, 2] %= 10;
 
171
        }
 
172
        
 
173
        public int CompoundAssignByRef(ref int i)
 
174
        {
 
175
                return i <<= 2;
 
176
        }
 
177
        
 
178
        public unsafe double CompoundAssignByPointer(double* ptr)
 
179
        {
 
180
                return *ptr /= 1.5;
 
181
        }
 
182
        
 
183
        public void CompoundAssignEnum()
 
184
        {
 
185
                this.enumField |= IncrementDecrement.MyEnum.Two;
 
186
                this.enumField &= ~IncrementDecrement.MyEnum.Four;
 
187
        }
 
188
        
 
189
        public int PostIncrementInAddition(int i, int j)
 
190
        {
 
191
                return i++ + j;
 
192
        }
 
193
        
 
194
        public void PostIncrementInlineLocalVariable(Func<int, int> f)
 
195
        {
 
196
                int num = 0;
 
197
                f(num++);
 
198
        }
 
199
        
 
200
        public int PostIncrementArrayElement(int[] array, int pos)
 
201
        {
 
202
                return array[pos]--;
 
203
        }
 
204
        
 
205
        public int PostIncrementStaticField()
 
206
        {
 
207
                return IncrementDecrement.StaticField++;
 
208
        }
 
209
        
 
210
        public int PostIncrementStaticProperty()
 
211
        {
 
212
                return IncrementDecrement.StaticProperty++;
 
213
        }
 
214
        
 
215
        public int PostIncrementInstanceField(IncrementDecrement.MutableClass m)
 
216
        {
 
217
                return m.Field++;
 
218
        }
 
219
        
 
220
//      public uint PostIncrementIndexer(string name)
 
221
//      {
 
222
//              return this.M()[name]++;
 
223
//      }
 
224
 
 
225
//      public unsafe int PostIncrementOfPointer(int* ptr)
 
226
//      {
 
227
//              return *(ptr++);
 
228
//      }
 
229
 
 
230
        public int PostIncrementInstanceField()
 
231
        {
 
232
                return this.M().Field--;
 
233
        }
 
234
        
 
235
        public int PostIncrementInstanceProperty()
 
236
        {
 
237
                return this.M().Property--;
 
238
        }
 
239
        
 
240
        public int PostIncrement2DArray()
 
241
        {
 
242
                return this.Array()[IncrementDecrement.StaticField, IncrementDecrement.StaticProperty]++;
 
243
        }
 
244
        
 
245
        public int PostIncrementByRef(ref int i)
 
246
        {
 
247
                return i++;
 
248
        }
 
249
        
 
250
        public unsafe int PostIncrementByPointer()
 
251
        {
 
252
                return (*this.GetPointer())++;
 
253
        }
 
254
}