Browse Source

Extended debugger test FunctionVariablesLifetime to check for "Function Expired" bug

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1114 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 20 years ago
parent
commit
12a1741d0f
  1. 25
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/DebuggerTests.cs
  2. 8
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/FunctionVariablesLifetime.cs

25
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/DebuggerTests.cs

@ -372,9 +372,10 @@ namespace Debugger.Tests @@ -372,9 +372,10 @@ namespace Debugger.Tests
Function function = null;
Variable argument = null;
Variable local = null;
Variable localInSubFunction = null;
Variable @class = null;
StartProgram("FunctionVariablesLifetime");
StartProgram("FunctionVariablesLifetime"); // 1 - Enter program
WaitForPause(PausedReason.Break, null);
function = debugger.CurrentFunction;
Assert.IsNotNull(function);
@ -396,19 +397,35 @@ namespace Debugger.Tests @@ -396,19 +397,35 @@ namespace Debugger.Tests
Assert.AreEqual("2", local.Value.AsString);
Assert.AreEqual("3", @class.Value.AsString);
debugger.Continue(); // Go to the SubFunction
debugger.Continue(); // 2 - Go to the SubFunction
WaitForPause(PausedReason.Break, null);
Assert.AreEqual("1", argument.Value.AsString);
Assert.AreEqual("2", local.Value.AsString);
Assert.AreEqual("3", @class.Value.AsString);
// Check localInSubFunction variable
localInSubFunction = debugger.LocalVariables["localInSubFunction"];
Assert.AreEqual("4", localInSubFunction.Value.AsString);
debugger.Continue(); // Go back to Function
debugger.Continue(); // 3 - Go back to Function
WaitForPause(PausedReason.Break, null);
Assert.AreEqual("1", argument.Value.AsString);
Assert.AreEqual("2", local.Value.AsString);
Assert.AreEqual("3", @class.Value.AsString);
// localInSubFunction should be dead now
Assert.AreEqual(typeof(UnavailableValue), localInSubFunction.Value.GetType());
debugger.Continue(); // Setp out of function
debugger.Continue(); // 4 - Go to the SubFunction
WaitForPause(PausedReason.Break, null);
Assert.AreEqual("1", argument.Value.AsString);
Assert.AreEqual("2", local.Value.AsString);
Assert.AreEqual("3", @class.Value.AsString);
// localInSubFunction should be still dead...
Assert.AreEqual(typeof(UnavailableValue), localInSubFunction.Value.GetType());
// ... , but we should able to get new one
localInSubFunction = debugger.LocalVariables["localInSubFunction"];
Assert.AreEqual("4", localInSubFunction.Value.AsString);
debugger.Continue(); // 5 - Setp out of both functions
WaitForPause(PausedReason.Break, null);
Assert.AreEqual(typeof(UnavailableValue), argument.Value.GetType());
Assert.AreEqual(typeof(UnavailableValue), local.Value.GetType());

8
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/FunctionVariablesLifetime.cs

@ -7,6 +7,8 @@ @@ -7,6 +7,8 @@
using System;
//CS0219: The variable 'variable' is assigned but its value is never used
//CS0414: The private field 'field' is assigned but its value is never used
#pragma warning disable 0219, 0414
namespace Debugger.Tests.TestPrograms
@ -18,7 +20,7 @@ namespace Debugger.Tests.TestPrograms @@ -18,7 +20,7 @@ namespace Debugger.Tests.TestPrograms
public static void Main()
{
new FunctionVariablesLifetime().Function(1);
System.Diagnostics.Debugger.Break(); // 4
System.Diagnostics.Debugger.Break(); // 5
}
void Function(int argument)
@ -27,11 +29,13 @@ namespace Debugger.Tests.TestPrograms @@ -27,11 +29,13 @@ namespace Debugger.Tests.TestPrograms
System.Diagnostics.Debugger.Break(); // 1
SubFunction();
System.Diagnostics.Debugger.Break(); // 3
SubFunction();
}
void SubFunction()
{
System.Diagnostics.Debugger.Break(); // 2
int localInSubFunction = 4;
System.Diagnostics.Debugger.Break(); // 2, 4
}
}
}

Loading…
Cancel
Save