[jit] Fix the saving of the 'cfg->ret_var_set' flag when inlining, it was set to...
[mono.git] / mcs / tests / test-iter-07.cs
1 // Compiler options: -langversion:default
2
3 using System;
4 using System.Collections;
5
6 public class Test
7 {
8         public IEnumerable Foo (int a)
9         {
10                 try {
11                         try {
12                                 yield return a;
13                         } finally {
14                                 Console.WriteLine ("Hello World");
15                         }
16
17                         Console.WriteLine ("Next block");
18
19                         try {
20                                 yield return a * a;
21                         } finally {
22                                 Console.WriteLine ("Boston");
23                         }
24                 } finally {
25                         Console.WriteLine ("Outer finally");
26                 }
27
28                 Console.WriteLine ("Outer block");
29                 yield break;
30         }
31 }
32
33 class X
34 {
35         public static int Main ()
36         {
37                 Test test = new Test ();
38
39                 ArrayList list = new ArrayList ();
40                 foreach (object o in test.Foo (5))
41                         list.Add (o);
42
43                 if (list.Count != 2)
44                         return 1;
45                 if ((int) list [0] != 5)
46                         return 2;
47                 if ((int) list [1] != 25)
48                         return 3;
49
50                 IEnumerable a = test.Foo (5);
51
52                 IEnumerator b = a as IEnumerator;
53                 if (b != null) {
54                         if (b.MoveNext ())
55                                 return 4;
56                 }
57
58                 IEnumerator c = a.GetEnumerator ();
59                 if (!c.MoveNext ())
60                         return 5;
61                 if ((int) c.Current != 5)
62                         return 6;
63                 if (!c.MoveNext ())
64                         return 7;
65                 if ((int) c.Current != 25)
66                         return 8;
67
68                 IEnumerator d = a.GetEnumerator ();
69
70                 if ((int) c.Current != 25)
71                         return 9;
72                 if (!d.MoveNext ())
73                         return 10;
74                 if ((int) c.Current != 25)
75                         return 11;
76                 if ((int) d.Current != 5)
77                         return 12;
78
79                 if (c.MoveNext ())
80                         return 13;
81
82                 ((IDisposable) a).Dispose ();
83                 return 0;
84         }
85 }