[jit] Fix the saving of the 'cfg->ret_var_set' flag when inlining, it was set to...
[mono.git] / mcs / tests / test-iter-06.cs
1 // Compiler options: -langversion:default
2
3 using System;
4 using System.Collections;
5
6 struct S {
7         int j;
8         
9         public IEnumerable Get (int a)
10         {
11                 Console.WriteLine ("Sending: " + a);
12                 yield return a;
13                 j = 10;
14                 Console.WriteLine ("Sending: " + j);
15                 yield return j;
16         }
17
18         public static IEnumerable GetS (int a)
19         {
20                 yield return 100;
21                 yield return a;
22                 yield return 1000;
23         }
24 }
25
26 class X {
27         IEnumerable Get (int a)
28         {
29                 yield return 1;
30                 yield return 2;
31                 yield return a;
32         }
33
34         static IEnumerable GetS (int a)
35         {
36                 yield return a;
37                 yield return a;
38                 yield return 1;
39         }
40         
41         public static int Main ()
42         {
43                 X y = new X ();
44
45                 int total = 0;
46                 foreach (int x in y.Get (5)){
47                         total += x;
48                 }
49                 if (total != 8)
50                         return 1;
51
52                 total = 0;
53                 foreach (int x in GetS (3)){
54                         total += x;
55                 }
56                 if (total != 7)
57                         return 2;
58
59                 S s = new S();
60                 total = 0;
61                 foreach (int x in s.Get (100)){
62                         Console.WriteLine ("Got: " + x);
63                         total += x;
64                 }
65                 if (total != 110)
66                         return 3;
67
68                 total = 0;
69                 foreach (int x in S.GetS (1)){
70                         total += x;
71                 }
72                 if (total != 1101)
73                         return 4;
74                 
75                 Console.WriteLine ("OK");
76                 return 0;
77         }
78 }