~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/Debugger/Debugger.Tests/Tests/StackFrame_VariablesLifetime.cs

  • Committer: sk
  • Date: 2011-09-10 05:17:57 UTC
  • Revision ID: halega@halega.com-20110910051757-qfouz1llya9m6boy
4.1.0.7915 Release Candidate 1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
 
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
 
3
 
 
4
using System;
 
5
 
 
6
namespace Debugger.Tests
 
7
{
 
8
        public class StackFrame_VariablesLifetime
 
9
        {
 
10
                public int @class = 3;
 
11
                
 
12
                public static void Main()
 
13
                {
 
14
                        new StackFrame_VariablesLifetime().Function(1);
 
15
                        System.Diagnostics.Debugger.Break(); // 5
 
16
                }
 
17
                
 
18
                void Function(int argument)
 
19
                {
 
20
                        int local = 2;
 
21
                        System.Diagnostics.Debugger.Break(); // 1
 
22
                        SubFunction();
 
23
                        System.Diagnostics.Debugger.Break(); // 3
 
24
                        SubFunction();
 
25
                }
 
26
                
 
27
                void SubFunction()
 
28
                {
 
29
                        int localInSubFunction = 4;
 
30
                        System.Diagnostics.Debugger.Break(); // 2, 4
 
31
                }
 
32
        }
 
33
}
 
34
 
 
35
#if TEST_CODE
 
36
namespace Debugger.Tests {
 
37
        public partial class DebuggerTests
 
38
        {
 
39
                [NUnit.Framework.Test]
 
40
                public void StackFrame_VariablesLifetime()
 
41
                {
 
42
                        Value argument = null;
 
43
                        Value local    = null;
 
44
                        Value localInSubFunction = null;
 
45
                        Value @class   = null;
 
46
                        
 
47
                        StartTest(); // 1 - Enter program
 
48
                        
 
49
                        argument = process.SelectedStackFrame.GetArgumentValue(0);
 
50
                        local = process.SelectedStackFrame.GetLocalVariableValue("local");
 
51
                        @class = process.SelectedStackFrame.GetThisValue().GetMemberValue("class");
 
52
                        ObjectDump("argument", argument);
 
53
                        ObjectDump("local", local);
 
54
                        ObjectDump("@class", @class);
 
55
                        
 
56
                        process.Continue(); // 2 - Go to the SubFunction
 
57
                        localInSubFunction = process.SelectedStackFrame.GetLocalVariableValue("localInSubFunction");
 
58
                        ObjectDump("argument", argument);
 
59
                        ObjectDump("local", local);
 
60
                        ObjectDump("@class", @class);
 
61
                        ObjectDump("localInSubFunction", @localInSubFunction);
 
62
                        
 
63
                        process.Continue(); // 3 - Go back to Function
 
64
                        ObjectDump("argument", argument);
 
65
                        ObjectDump("local", local);
 
66
                        ObjectDump("@class", @class);
 
67
                        ObjectDump("localInSubFunction", @localInSubFunction);
 
68
                        
 
69
                        process.Continue(); // 4 - Go to the SubFunction
 
70
                        ObjectDump("argument", argument);
 
71
                        ObjectDump("local", local);
 
72
                        ObjectDump("@class", @class);
 
73
                        ObjectDump("localInSubFunction", @localInSubFunction);
 
74
                        localInSubFunction = process.SelectedStackFrame.GetLocalVariableValue("localInSubFunction");
 
75
                        ObjectDump("localInSubFunction(new)", @localInSubFunction);
 
76
                        
 
77
                        process.Continue(); // 5 - Setp out of both functions
 
78
                        ObjectDump("argument", argument);
 
79
                        ObjectDump("local", local);
 
80
                        ObjectDump("@class", @class);
 
81
                        ObjectDump("localInSubFunction", @localInSubFunction);
 
82
                        
 
83
                        EndTest();
 
84
                }
 
85
        }
 
86
}
 
87
#endif
 
88
 
 
89
#if EXPECTED_OUTPUT
 
90
<?xml version="1.0" encoding="utf-8"?>
 
91
<DebuggerTests>
 
92
  <Test
 
93
    name="StackFrame_VariablesLifetime.cs">
 
94
    <ProcessStarted />
 
95
    <ModuleLoaded>mscorlib.dll (No symbols)</ModuleLoaded>
 
96
    <ModuleLoaded>StackFrame_VariablesLifetime.exe (Has symbols)</ModuleLoaded>
 
97
    <DebuggingPaused>Break StackFrame_VariablesLifetime.cs:21,4-21,40</DebuggingPaused>
 
98
    <argument>
 
99
      <Value
 
100
        PrimitiveValue="1"
 
101
        Type="System.Int32" />
 
102
    </argument>
 
103
    <local>
 
104
      <Value
 
105
        PrimitiveValue="2"
 
106
        Type="System.Int32" />
 
107
    </local>
 
108
    <_x0040_class>
 
109
      <Value
 
110
        PrimitiveValue="3"
 
111
        Type="System.Int32" />
 
112
    </_x0040_class>
 
113
    <DebuggingPaused>Break StackFrame_VariablesLifetime.cs:30,4-30,40</DebuggingPaused>
 
114
    <argument>
 
115
      <Value
 
116
        IsInvalid="True"
 
117
        IsReference="{Exception: Value is no longer valid}"
 
118
        PrimitiveValue="{Exception: Value is no longer valid}"
 
119
        Type="System.Int32" />
 
120
    </argument>
 
121
    <local>
 
122
      <Value
 
123
        IsInvalid="True"
 
124
        IsReference="{Exception: Value is no longer valid}"
 
125
        PrimitiveValue="{Exception: Value is no longer valid}"
 
126
        Type="System.Int32" />
 
127
    </local>
 
128
    <_x0040_class>
 
129
      <Value
 
130
        IsInvalid="True"
 
131
        IsReference="{Exception: Value is no longer valid}"
 
132
        PrimitiveValue="{Exception: Value is no longer valid}"
 
133
        Type="System.Int32" />
 
134
    </_x0040_class>
 
135
    <localInSubFunction>
 
136
      <Value
 
137
        PrimitiveValue="4"
 
138
        Type="System.Int32" />
 
139
    </localInSubFunction>
 
140
    <DebuggingPaused>Break StackFrame_VariablesLifetime.cs:23,4-23,40</DebuggingPaused>
 
141
    <argument>
 
142
      <Value
 
143
        IsInvalid="True"
 
144
        IsReference="{Exception: Value is no longer valid}"
 
145
        PrimitiveValue="{Exception: Value is no longer valid}"
 
146
        Type="System.Int32" />
 
147
    </argument>
 
148
    <local>
 
149
      <Value
 
150
        IsInvalid="True"
 
151
        IsReference="{Exception: Value is no longer valid}"
 
152
        PrimitiveValue="{Exception: Value is no longer valid}"
 
153
        Type="System.Int32" />
 
154
    </local>
 
155
    <_x0040_class>
 
156
      <Value
 
157
        IsInvalid="True"
 
158
        IsReference="{Exception: Value is no longer valid}"
 
159
        PrimitiveValue="{Exception: Value is no longer valid}"
 
160
        Type="System.Int32" />
 
161
    </_x0040_class>
 
162
    <localInSubFunction>
 
163
      <Value
 
164
        IsInvalid="True"
 
165
        IsReference="{Exception: Value is no longer valid}"
 
166
        PrimitiveValue="{Exception: Value is no longer valid}"
 
167
        Type="System.Int32" />
 
168
    </localInSubFunction>
 
169
    <DebuggingPaused>Break StackFrame_VariablesLifetime.cs:30,4-30,40</DebuggingPaused>
 
170
    <argument>
 
171
      <Value
 
172
        IsInvalid="True"
 
173
        IsReference="{Exception: Value is no longer valid}"
 
174
        PrimitiveValue="{Exception: Value is no longer valid}"
 
175
        Type="System.Int32" />
 
176
    </argument>
 
177
    <local>
 
178
      <Value
 
179
        IsInvalid="True"
 
180
        IsReference="{Exception: Value is no longer valid}"
 
181
        PrimitiveValue="{Exception: Value is no longer valid}"
 
182
        Type="System.Int32" />
 
183
    </local>
 
184
    <_x0040_class>
 
185
      <Value
 
186
        IsInvalid="True"
 
187
        IsReference="{Exception: Value is no longer valid}"
 
188
        PrimitiveValue="{Exception: Value is no longer valid}"
 
189
        Type="System.Int32" />
 
190
    </_x0040_class>
 
191
    <localInSubFunction>
 
192
      <Value
 
193
        IsInvalid="True"
 
194
        IsReference="{Exception: Value is no longer valid}"
 
195
        PrimitiveValue="{Exception: Value is no longer valid}"
 
196
        Type="System.Int32" />
 
197
    </localInSubFunction>
 
198
    <localInSubFunction_x0028_new_x0029_>
 
199
      <Value
 
200
        PrimitiveValue="4"
 
201
        Type="System.Int32" />
 
202
    </localInSubFunction_x0028_new_x0029_>
 
203
    <DebuggingPaused>Break StackFrame_VariablesLifetime.cs:15,4-15,40</DebuggingPaused>
 
204
    <argument>
 
205
      <Value
 
206
        IsInvalid="True"
 
207
        IsReference="{Exception: Value is no longer valid}"
 
208
        PrimitiveValue="{Exception: Value is no longer valid}"
 
209
        Type="System.Int32" />
 
210
    </argument>
 
211
    <local>
 
212
      <Value
 
213
        IsInvalid="True"
 
214
        IsReference="{Exception: Value is no longer valid}"
 
215
        PrimitiveValue="{Exception: Value is no longer valid}"
 
216
        Type="System.Int32" />
 
217
    </local>
 
218
    <_x0040_class>
 
219
      <Value
 
220
        IsInvalid="True"
 
221
        IsReference="{Exception: Value is no longer valid}"
 
222
        PrimitiveValue="{Exception: Value is no longer valid}"
 
223
        Type="System.Int32" />
 
224
    </_x0040_class>
 
225
    <localInSubFunction>
 
226
      <Value
 
227
        IsInvalid="True"
 
228
        IsReference="{Exception: Value is no longer valid}"
 
229
        PrimitiveValue="{Exception: Value is no longer valid}"
 
230
        Type="System.Int32" />
 
231
    </localInSubFunction>
 
232
    <ProcessExited />
 
233
  </Test>
 
234
</DebuggerTests>
 
235
#endif // EXPECTED_OUTPUT