Browse Source

Added debugger test: PropertyVariable

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@883 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 20 years ago
parent
commit
d3b6bd0d16
  1. 1
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Debugger.Tests.csproj
  2. 66
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/DebuggerTests.cs
  3. 1
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestProgram.cs
  4. 45
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/PropertyVariable.cs

1
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Debugger.Tests.csproj

@ -50,6 +50,7 @@
<Compile Include="Src\TestPrograms\FunctionLifetime.cs" /> <Compile Include="Src\TestPrograms\FunctionLifetime.cs" />
<Compile Include="Src\TestPrograms\FunctionVariablesLifetime.cs" /> <Compile Include="Src\TestPrograms\FunctionVariablesLifetime.cs" />
<Compile Include="Src\TestPrograms\ObjectValue.cs" /> <Compile Include="Src\TestPrograms\ObjectValue.cs" />
<Compile Include="Src\TestPrograms\PropertyVariable.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Src" /> <Folder Include="Src" />

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

@ -236,15 +236,15 @@ namespace Debugger.Tests
debugger.Continue(); debugger.Continue();
WaitForPause(PausedReason.Break, null); WaitForPause(PausedReason.Break, null);
args = new List<Variable>(debugger.CurrentFunction.ArgumentVariables); args = new List<Variable>(debugger.CurrentFunction.ArgumentVariables);
// Argument names // names
Assert.AreEqual("i", args[0].Name); Assert.AreEqual("i", args[0].Name);
Assert.AreEqual("s", args[1].Name); Assert.AreEqual("s", args[1].Name);
Assert.AreEqual("args", args[2].Name); Assert.AreEqual("args", args[2].Name);
// Argument types // types
Assert.AreEqual(typeof(PrimitiveValue), args[0].Value.GetType()); Assert.AreEqual(typeof(PrimitiveValue), args[0].Value.GetType());
Assert.AreEqual(typeof(PrimitiveValue), args[1].Value.GetType()); Assert.AreEqual(typeof(PrimitiveValue), args[1].Value.GetType());
Assert.AreEqual(typeof(ArrayValue), args[2].Value.GetType()); Assert.AreEqual(typeof(ArrayValue), args[2].Value.GetType());
// Argument values // values
Assert.AreEqual("0", args[0].Value.AsString); Assert.AreEqual("0", args[0].Value.AsString);
Assert.AreEqual("S", args[1].Value.AsString); Assert.AreEqual("S", args[1].Value.AsString);
Assert.AreEqual(0 ,((ArrayValue)args[2].Value).Lenght); Assert.AreEqual(0 ,((ArrayValue)args[2].Value).Lenght);
@ -252,11 +252,11 @@ namespace Debugger.Tests
debugger.Continue(); debugger.Continue();
WaitForPause(PausedReason.Break, null); WaitForPause(PausedReason.Break, null);
args = new List<Variable>(debugger.CurrentFunction.ArgumentVariables); args = new List<Variable>(debugger.CurrentFunction.ArgumentVariables);
// Argument types // types
Assert.AreEqual(typeof(PrimitiveValue), args[0].Value.GetType()); Assert.AreEqual(typeof(PrimitiveValue), args[0].Value.GetType());
Assert.AreEqual(typeof(PrimitiveValue), args[1].Value.GetType()); Assert.AreEqual(typeof(PrimitiveValue), args[1].Value.GetType());
Assert.AreEqual(typeof(ArrayValue), args[2].Value.GetType()); Assert.AreEqual(typeof(ArrayValue), args[2].Value.GetType());
// Argument values // values
Assert.AreEqual("1", args[0].Value.AsString); Assert.AreEqual("1", args[0].Value.AsString);
Assert.AreEqual("S", args[1].Value.AsString); Assert.AreEqual("S", args[1].Value.AsString);
Assert.AreEqual(1 ,((ArrayValue)args[2].Value).Lenght); Assert.AreEqual(1 ,((ArrayValue)args[2].Value).Lenght);
@ -264,11 +264,11 @@ namespace Debugger.Tests
debugger.Continue(); debugger.Continue();
WaitForPause(PausedReason.Break, null); WaitForPause(PausedReason.Break, null);
args = new List<Variable>(debugger.CurrentFunction.ArgumentVariables); args = new List<Variable>(debugger.CurrentFunction.ArgumentVariables);
// Argument types // types
Assert.AreEqual(typeof(PrimitiveValue), args[0].Value.GetType()); Assert.AreEqual(typeof(PrimitiveValue), args[0].Value.GetType());
Assert.AreEqual(typeof(NullValue), args[1].Value.GetType()); Assert.AreEqual(typeof(NullValue), args[1].Value.GetType());
Assert.AreEqual(typeof(ArrayValue), args[2].Value.GetType()); Assert.AreEqual(typeof(ArrayValue), args[2].Value.GetType());
// Argument values // values
Assert.AreEqual("2", args[0].Value.AsString); Assert.AreEqual("2", args[0].Value.AsString);
Assert.IsNotNull(args[1].Value.AsString); Assert.IsNotNull(args[1].Value.AsString);
Assert.AreEqual(2 ,((ArrayValue)args[2].Value).Lenght); Assert.AreEqual(2 ,((ArrayValue)args[2].Value).Lenght);
@ -286,19 +286,19 @@ namespace Debugger.Tests
StartProgram("FunctionLocalVariables"); StartProgram("FunctionLocalVariables");
WaitForPause(PausedReason.Break, null); WaitForPause(PausedReason.Break, null);
args = new List<Variable>(debugger.CurrentFunction.LocalVariables); args = new List<Variable>(debugger.CurrentFunction.LocalVariables);
// Argument names // names
Assert.AreEqual("i", args[0].Name); Assert.AreEqual("i", args[0].Name);
Assert.AreEqual("s", args[1].Name); Assert.AreEqual("s", args[1].Name);
Assert.AreEqual("args", args[2].Name); Assert.AreEqual("args", args[2].Name);
Assert.AreEqual("n", args[3].Name); Assert.AreEqual("n", args[3].Name);
Assert.AreEqual("o", args[4].Name); Assert.AreEqual("o", args[4].Name);
// Argument types // types
Assert.AreEqual(typeof(PrimitiveValue), args[0].Value.GetType()); Assert.AreEqual(typeof(PrimitiveValue), args[0].Value.GetType());
Assert.AreEqual(typeof(PrimitiveValue), args[1].Value.GetType()); Assert.AreEqual(typeof(PrimitiveValue), args[1].Value.GetType());
Assert.AreEqual(typeof(ArrayValue), args[2].Value.GetType()); Assert.AreEqual(typeof(ArrayValue), args[2].Value.GetType());
Assert.AreEqual(typeof(NullValue), args[3].Value.GetType()); Assert.AreEqual(typeof(NullValue), args[3].Value.GetType());
Assert.AreEqual(typeof(ObjectValue), args[4].Value.GetType()); Assert.AreEqual(typeof(ObjectValue), args[4].Value.GetType());
// Argument values // values
Assert.AreEqual("0", args[0].Value.AsString); Assert.AreEqual("0", args[0].Value.AsString);
Assert.AreEqual("S", args[1].Value.AsString); Assert.AreEqual("S", args[1].Value.AsString);
Assert.AreEqual(1 ,((ArrayValue)args[2].Value).Lenght); Assert.AreEqual(1 ,((ArrayValue)args[2].Value).Lenght);
@ -435,5 +435,51 @@ namespace Debugger.Tests
debugger.Continue(); debugger.Continue();
debugger.WaitForPrecessExit(); debugger.WaitForPrecessExit();
} }
[Test]
public void PropertyVariable()
{
Variable local = null;
List<Variable> subVars = new List<Variable>();
StartProgram("PropertyVariable");
WaitForPause(PausedReason.Break, null);
foreach(Variable var in debugger.CurrentFunction.LocalVariables) {
local = var;
}
foreach(Variable var in local.SubVariables) {
subVars.Add(var);
}
Assert.AreEqual("PrivateProperty", subVars[1].Name);
Assert.AreEqual("PublicProperty", subVars[2].Name);
Assert.AreEqual("ExceptionProperty", subVars[3].Name);
Assert.AreEqual("StaticProperty", subVars[4].Name);
Assert.AreEqual(typeof(UnavailableValue), subVars[1].Value.GetType());
debugger.StartEvaluation();
WaitForPause(PausedReason.AllEvalsComplete, null);
Assert.AreEqual("private", subVars[1].Value.AsString);
Assert.AreEqual(typeof(UnavailableValue), subVars[2].Value.GetType());
debugger.StartEvaluation();
WaitForPause(PausedReason.AllEvalsComplete, null);
Assert.AreEqual("public", subVars[2].Value.AsString);
Assert.AreEqual(typeof(UnavailableValue), subVars[3].Value.GetType());
debugger.StartEvaluation();
WaitForPause(PausedReason.AllEvalsComplete, null);
Assert.AreEqual(typeof(UnavailableValue), subVars[3].Value);
Assert.AreEqual(typeof(UnavailableValue), subVars[4].Value.GetType());
debugger.StartEvaluation();
WaitForPause(PausedReason.AllEvalsComplete, null);
Assert.AreEqual("static", subVars[4].Value.AsString);
debugger.Continue();
WaitForPause(PausedReason.Break, null);
debugger.Continue();
debugger.WaitForPrecessExit();
}
} }
} }

1
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestProgram.cs

@ -29,6 +29,7 @@ namespace Debugger.Tests
case "FunctionVariablesLifetime": Progs.FunctionVariablesLifetime.Main(); break; case "FunctionVariablesLifetime": Progs.FunctionVariablesLifetime.Main(); break;
case "HelloWorld": Progs.HelloWorld.Main(); break; case "HelloWorld": Progs.HelloWorld.Main(); break;
case "ObjectValue": Progs.ObjectValue.Main(); break; case "ObjectValue": Progs.ObjectValue.Main(); break;
case "PropertyVariable": Progs.PropertyVariable.Main(); break;
case "SimpleProgram": Progs.SimpleProgram.Main(); break; case "SimpleProgram": Progs.SimpleProgram.Main(); break;
case "Stepping": Progs.Stepping.Main(); break; case "Stepping": Progs.Stepping.Main(); break;
case "Symbols": Progs.Symbols.Main(); break; case "Symbols": Progs.Symbols.Main(); break;

45
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/PropertyVariable.cs

@ -0,0 +1,45 @@
// <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System;
namespace Debugger.Tests.TestPrograms
{
public class PropertyVariable
{
string PrivateProperty {
get {
return "private";
}
}
public string PublicProperty {
get {
return "public";
}
}
public string ExceptionProperty {
get {
throw new NotSupportedException();
}
}
public static string StaticProperty {
get {
return "static";
}
}
public static void Main()
{
PropertyVariable var = new PropertyVariable();
System.Diagnostics.Debugger.Break();
System.Diagnostics.Debugger.Break();
}
}
}
Loading…
Cancel
Save