2007-05-25 Jonathan Chambers <joncham@gmail.com>
[mcs.git] / tests / test-121.cs
blob21e96bc967f287e551894ca4c66e2c1e9a127422
1 //
2 // This test excercises the fact that array evaluation in UnaryMutator and
3 // CompoundAssign expressions should never mutate data more than once
4 //
5 class X {
6 static int g_calls;
8 static int g ()
10 g_calls++;
11 return 0;
15 static int Main ()
17 int [] a = new int [10];
18 int i = 0;
20 a [0] = 1;
22 a [i++] += 3;
24 if (i != 1)
25 return 1;
26 if (a [0] != 4)
27 return 2;
29 a [g ()]++ ;
31 if (g_calls != 1)
32 return 3;
33 return 0;