blob: 562b1a526a41a0b9c5390f9f2af399ac232adb1d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
// Compiler options: -langversion:default
using System;
using System.Collections;
public class Foo : IDisposable
{
public readonly int Data;
public Foo (int data)
{
this.Data = data;
}
public bool disposed;
public void Dispose ()
{
disposed = true;
}
}
class X
{
public static IEnumerable Test (int a, int b)
{
Foo foo3, foo4;
using (Foo foo1 = new Foo (a), foo2 = new Foo (b)) {
yield return foo1.Data;
yield return foo2.Data;
foo3 = foo1;
foo4 = foo2;
}
yield return foo3.disposed;
yield return foo4.disposed;
}
public static int Main ()
{
ArrayList list = new ArrayList ();
foreach (object data in Test (3, 5))
list.Add (data);
if (list.Count != 4)
return 1;
if ((int) list [0] != 3)
return 2;
if ((int) list [1] != 5)
return 3;
if (!(bool) list [2])
return 4;
if (!(bool) list [3])
return 5;
return 0;
}
}
|