blob: 87038d5273e746429d92ec77e780e87c23a6622b (
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
class Class1
{
private static TestUtil.TestLog testLog;
static Class1()
{
// Create test writer object to hold expected output
System.IO.StringWriter expectedOut = new System.IO.StringWriter();
// Write expected output to string writer object
expectedOut.WriteLine("in main try");
expectedOut.WriteLine(" in middle1 try");
expectedOut.WriteLine(" in middle1 finally");
expectedOut.WriteLine(" in middle2 try");
expectedOut.WriteLine(" in middle2 finally");
expectedOut.WriteLine("in main catch");
expectedOut.WriteLine("in main finally");
// Create and initialize test log object
testLog = new TestUtil.TestLog(expectedOut);
}
static public void Middle1(int i)
{
try
{
Console.WriteLine(" in middle1 try");
if (i == 0) goto L1;
}
catch
{
Console.WriteLine(" in middle1 catch");
}
finally
{
Console.WriteLine(" in middle1 finally");
Middle2(i);
if (i == 0) throw new Exception();
}
Console.WriteLine("after middle1 finally");
L1:
Console.WriteLine("middle1 L1");
}
static public void Middle2(int i)
{
try
{
Console.WriteLine(" in middle2 try");
if (i == 0) goto L2;
}
catch
{
Console.WriteLine(" in middle2 catch");
}
finally
{
Console.WriteLine(" in middle2 finally");
if (i == 0) throw new Exception();
}
Console.WriteLine("after middle2 finally");
L2:
Console.WriteLine("middle2 L2");
}
static public int Main(string[] args)
{
// start recording
testLog.StartRecording();
int i = Environment.TickCount != 0 ? 0 : 1;
try
{
Console.WriteLine("in main try");
Middle1(i);
}
catch
{
Console.WriteLine("in main catch");
}
finally
{
Console.WriteLine("in main finally");
}
// stop recoding
testLog.StopRecording();
return testLog.VerifyOutput();
}
}
|