Skip to content

Commit 66ad4d7

Browse files
committed
Added test for evaluation
1 parent 81ed75f commit 66ad4d7

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

MonoDevelop.Debugger.Tests.TestApp/AdvancedEvaluation.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,39 @@ public async Task Bug24998 ()
8585
action ();
8686
someVariable.Add (someField);/*cc622137-a162-4b91-a85c-88241e68c3ea*/
8787
}
88+
89+
90+
public void InvocationsCountDuringExpandingTest ()
91+
{
92+
var mutableFieldClass = new MutableFieldClass ();
93+
Console.WriteLine("InvocationsCountDuringExpandingTest breakpoint");/*8865cace-6b57-42cc-ad55-68a2c12dd3d7*/
94+
}
95+
96+
class MutableFieldClass
97+
{
98+
int sharedX = 0;
99+
100+
public MutableField Prop1
101+
{
102+
get { return new MutableField(sharedX++); }
103+
}
104+
105+
public MutableField Prop2
106+
{
107+
get { return new MutableField(sharedX++); }
108+
}
109+
}
110+
111+
112+
class MutableField
113+
{
114+
int x;
115+
116+
public MutableField(int x)
117+
{
118+
this.x = x;
119+
}
120+
}
88121
}
89122
}
90123

MonoDevelop.Debugger.Tests/AdvancedEvaluationTests.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,36 @@ public void YieldMethodTest ()
150150
Assert.AreEqual (3, val.GetAllChildrenSync ().Length);
151151

152152
}
153+
154+
[Test]
155+
public void InvocationsCountDuringExpandingTest ()
156+
{
157+
InitializeTest ();
158+
AddBreakpoint ("8865cace-6b57-42cc-ad55-68a2c12dd3d7");
159+
StartTest ("InvocationsCountDuringExpandingTest");
160+
CheckPosition ("8865cace-6b57-42cc-ad55-68a2c12dd3d7");
161+
var options = Session.EvaluationOptions.Clone ();
162+
options.GroupPrivateMembers = false; // to access private fields (else there are in Private subgroup)
163+
var value = Eval ("mutableFieldClass");
164+
var sharedX = value.GetChildSync ("sharedX", options);
165+
Assert.NotNull (sharedX);
166+
167+
var prop1 = value.GetChildSync("Prop1", options);
168+
Assert.NotNull (prop1);
169+
Assert.AreEqual ("MonoDevelop.Debugger.Tests.TestApp.AdvancedEvaluation.MutableField", prop1.TypeName);
170+
var prop1X = prop1.GetChildSync ("x", options);
171+
Assert.NotNull (prop1X);
172+
Assert.AreEqual ("0", prop1X.Value); // before CorValRef optimization this field evaluated to 2,
173+
// because every value to the root object was recalculated - this was wrong behavior
174+
175+
var prop2 = value.GetChildSync ("Prop2", options);
176+
Assert.NotNull (prop2);
177+
var prop2X = prop2.GetChildSync("x", options);
178+
Assert.NotNull (prop2X);
179+
Assert.AreEqual ("1", prop2X.Value);
180+
181+
Assert.AreEqual ("2", sharedX.Value);
182+
}
153183
}
154184
}
155185

0 commit comments

Comments
 (0)