Browse Source

Expressions test merged into ExpressionEvaluator test;

Fixed base class of String

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5111 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 16 years ago
parent
commit
5b77ae5bd0
  1. 15
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Eval.cs
  2. 4
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Expressions/ExpressionEvaluator.cs
  3. 10
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/DebugType.cs
  4. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Values/Value.cs
  5. 2
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Debugger.Tests.csproj
  6. 35
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/DebugType.cs
  7. 104
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/ExpressionEvaluator.cs
  8. 356
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Expressions.cs

15
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Eval.cs

@ -230,13 +230,16 @@ namespace Debugger @@ -230,13 +230,16 @@ namespace Debugger
}
corArgs.Add(thisValue.CorValue);
}
foreach(Value arg in args) {
// TODO: It is importatnt to pass the parameted in the correct form (boxed/unboxed)
// This is just a good guess
if (arg.Type.IsValueType) {
corArgs.Add(arg.CorGenericValue.CastTo<ICorDebugValue>());
for(int i = 0; i < args.Length; i++) {
// It is importatnt to pass the parameted in the correct form (boxed/unboxed)
if (method.GetParameters()[i].ParameterType.IsValueType) {
corArgs.Add(args[i].CorGenericValue.CastTo<ICorDebugValue>());
} else {
corArgs.Add(arg.CorValue);
if (args[i].Type.IsValueType) {
corArgs.Add(args[i].Box().CorValue);
} else {
corArgs.Add(args[i].CorValue);
}
}
}

4
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Expressions/ExpressionEvaluator.cs

@ -113,6 +113,10 @@ namespace Debugger @@ -113,6 +113,10 @@ namespace Debugger
}
sb.Append("}");
return sb.ToString();
} else if (val.Type.FullName == typeof(char).FullName) {
return "'" + val.PrimitiveValue.ToString() + "'";
} else if (val.Type.FullName == typeof(string).FullName) {
return "\"" + val.PrimitiveValue.ToString() + "\"";
} else if (val.Type.IsPrimitive) {
return val.PrimitiveValue.ToString();
} else {

10
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/DebugType.cs

@ -29,7 +29,7 @@ namespace Debugger.MetaData @@ -29,7 +29,7 @@ namespace Debugger.MetaData
[Debugger.Tests.IgnoreOnException]
public class DebugType: System.Type, IDebugMemberInfo
{
public const BindingFlags BindingFlagsAll = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance;
public const BindingFlags BindingFlagsAll = BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance;
public const BindingFlags BindingFlagsAllDeclared = BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance;
Module module;
@ -147,7 +147,7 @@ namespace Debugger.MetaData @@ -147,7 +147,7 @@ namespace Debugger.MetaData
public override Type BaseType {
get {
// corType.Base *sometimes* does not work for object and can cause "Value does not fall within the expected range." exception
if (this.FullName == "System.Object") {
if (this.FullName == typeof(object).FullName) {
return null;
}
// corType.Base does not work for arrays
@ -155,9 +155,9 @@ namespace Debugger.MetaData @@ -155,9 +155,9 @@ namespace Debugger.MetaData
return DebugType.CreateFromType(this.AppDomain, typeof(Array));
}
// corType.Base does not work for primitive types
if (this.IsPrimitive) {
return DebugType.CreateFromType(this.AppDomain, typeof(ValueType));
}
// if (this.IsPrimitive) {
// return DebugType.CreateFromType(this.AppDomain, typeof(ValueType));
// }
if (this.IsPointer || corElementType == CorElementType.VOID) {
return null;
}

2
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Values/Value.cs

@ -98,7 +98,7 @@ namespace Debugger @@ -98,7 +98,7 @@ namespace Debugger
}
}
Value Box()
public Value Box()
{
byte[] rawValue = this.CorGenericValue.RawValue;
// Box the value type

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

@ -54,7 +54,6 @@ @@ -54,7 +54,6 @@
<Compile Include="Src\TestPrograms\ControlFlow_DebuggeeKilled.cs" />
<Compile Include="Src\TestPrograms\DebugType.cs" />
<Compile Include="Src\TestPrograms\Exception_Custom.cs" />
<Compile Include="Src\TestPrograms\Expressions.cs" />
<Compile Include="Src\TestPrograms\StackFrame_Lifetime.cs" />
<Compile Include="Src\TestPrograms\StackFrame_VariablesLifetime.cs" />
<Compile Include="Src\TestPrograms\Value_GenericDictionary.cs" />
@ -84,7 +83,6 @@ @@ -84,7 +83,6 @@
<EmbeddedResource Include="Src\TestPrograms\Exception_Custom.cs" />
<EmbeddedResource Include="Src\TestPrograms\Exception_StackOverflow.cs" />
<EmbeddedResource Include="Src\TestPrograms\ExpressionEvaluator.cs" />
<EmbeddedResource Include="Src\TestPrograms\Expressions.cs" />
<EmbeddedResource Include="Src\TestPrograms\Process_MemoryReadWrite.cs" />
<EmbeddedResource Include="Src\TestPrograms\StackFrame_Callstack.cs" />
<EmbeddedResource Include="Src\TestPrograms\StackFrame_Lifetime.cs" />

35
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/DebugType.cs

@ -84,6 +84,7 @@ namespace Debugger.Tests.TestPrograms @@ -84,6 +84,7 @@ namespace Debugger.Tests.TestPrograms
int i = 42;
bool b = true;
char c = 'a';
string s = "abc";
object obj = new object();
MyClass myClass = new MyClass();
MyStruct myStruct = new MyStruct();
@ -222,7 +223,7 @@ namespace Debugger.Tests { @@ -222,7 +223,7 @@ namespace Debugger.Tests {
<ProcessStarted />
<ModuleLoaded>mscorlib.dll (No symbols)</ModuleLoaded>
<ModuleLoaded>DebugType.exe (Has symbols)</ModuleLoaded>
<DebuggingPaused>Break DebugType.cs:137,4-137,40</DebuggingPaused>
<DebuggingPaused>Break DebugType.cs:138,4-138,40</DebuggingPaused>
<DefinedTypes
Capacity="16"
Count="13">
@ -520,15 +521,15 @@ namespace Debugger.Tests { @@ -520,15 +521,15 @@ namespace Debugger.Tests {
<Type>
<DebugType
Attributes="AutoLayout, AnsiClass, Class, Public, Sealed, Serializable, BeforeFieldInit"
BaseType="System.ValueType"
BaseType="System.Object"
FullName="System.String"
GetFields="{System.String Empty}"
GetInterfaces="{System.IComparable, System.ICloneable, System.IConvertible, System.IComparable`1[[System.String]], System.Collections.Generic.IEnumerable`1[[System.Char]], System.Collections.IEnumerable, System.IEquatable`1[[System.String]]}"
GetMembers="{System.String Empty, Join, Join, Equals, Equals, Equals, Equals, Equals, op_Equality, op_Inequality, get_Chars, CopyTo, ToCharArray, ToCharArray, IsNullOrEmpty, GetHashCode, get_Length, Split, Split, Split, Split, Split, Split, Substring, Substring, Trim, Trim, TrimStart, TrimEnd, .ctor, .ctor, .ctor, .ctor, .ctor, .ctor, .ctor, .ctor, IsNormalized, IsNormalized, Normalize, Normalize, Compare, Compare, Compare, Compare, Compare, Compare, Compare, Compare, Compare, Compare, CompareTo, CompareTo, CompareOrdinal, CompareOrdinal, Contains, EndsWith, EndsWith, EndsWith, IndexOf, IndexOf, IndexOf, IndexOf, IndexOf, IndexOf, IndexOf, IndexOf, IndexOf, IndexOfAny, IndexOfAny, IndexOfAny, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOfAny, LastIndexOfAny, LastIndexOfAny, PadLeft, PadLeft, PadRight, PadRight, StartsWith, StartsWith, StartsWith, ToLower, ToLower, ToLowerInvariant, ToUpper, ToUpper, ToUpperInvariant, ToString, ToString, Clone, Insert, Replace, Replace, Remove, Remove, Format, Format, Format, Format, Format, Copy, Concat, Concat, Concat, Concat, Concat, Concat, Concat, Concat, Concat, Intern, IsInterned, GetTypeCode, GetEnumerator, System.Char Chars, System.Int32 Length, Equals, GetHashCode, ToString, .ctor, ToString, Equals, GetHashCode, GetType}"
GetMethods="{Join, Join, Equals, Equals, Equals, Equals, Equals, op_Equality, op_Inequality, get_Chars, CopyTo, ToCharArray, ToCharArray, IsNullOrEmpty, GetHashCode, get_Length, Split, Split, Split, Split, Split, Split, Substring, Substring, Trim, Trim, TrimStart, TrimEnd, .ctor, .ctor, .ctor, .ctor, .ctor, .ctor, .ctor, .ctor, IsNormalized, IsNormalized, Normalize, Normalize, Compare, Compare, Compare, Compare, Compare, Compare, Compare, Compare, Compare, Compare, CompareTo, CompareTo, CompareOrdinal, CompareOrdinal, Contains, EndsWith, EndsWith, EndsWith, IndexOf, IndexOf, IndexOf, IndexOf, IndexOf, IndexOf, IndexOf, IndexOf, IndexOf, IndexOfAny, IndexOfAny, IndexOfAny, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOfAny, LastIndexOfAny, LastIndexOfAny, PadLeft, PadLeft, PadRight, PadRight, StartsWith, StartsWith, StartsWith, ToLower, ToLower, ToLowerInvariant, ToUpper, ToUpper, ToUpperInvariant, ToString, ToString, Clone, Insert, Replace, Replace, Remove, Remove, Format, Format, Format, Format, Format, Copy, Concat, Concat, Concat, Concat, Concat, Concat, Concat, Concat, Concat, Intern, IsInterned, GetTypeCode, GetEnumerator, Equals, GetHashCode, ToString, .ctor, ToString, Equals, GetHashCode, GetType}"
GetMembers="{System.String Empty, Join, Join, Equals, Equals, Equals, Equals, Equals, op_Equality, op_Inequality, get_Chars, CopyTo, ToCharArray, ToCharArray, IsNullOrEmpty, GetHashCode, get_Length, Split, Split, Split, Split, Split, Split, Substring, Substring, Trim, Trim, TrimStart, TrimEnd, .ctor, .ctor, .ctor, .ctor, .ctor, .ctor, .ctor, .ctor, IsNormalized, IsNormalized, Normalize, Normalize, Compare, Compare, Compare, Compare, Compare, Compare, Compare, Compare, Compare, Compare, CompareTo, CompareTo, CompareOrdinal, CompareOrdinal, Contains, EndsWith, EndsWith, EndsWith, IndexOf, IndexOf, IndexOf, IndexOf, IndexOf, IndexOf, IndexOf, IndexOf, IndexOf, IndexOfAny, IndexOfAny, IndexOfAny, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOfAny, LastIndexOfAny, LastIndexOfAny, PadLeft, PadLeft, PadRight, PadRight, StartsWith, StartsWith, StartsWith, ToLower, ToLower, ToLowerInvariant, ToUpper, ToUpper, ToUpperInvariant, ToString, ToString, Clone, Insert, Replace, Replace, Remove, Remove, Format, Format, Format, Format, Format, Copy, Concat, Concat, Concat, Concat, Concat, Concat, Concat, Concat, Concat, Intern, IsInterned, GetTypeCode, GetEnumerator, System.Char Chars, System.Int32 Length, .ctor, ToString, Equals, GetHashCode, GetType}"
GetMethods="{Join, Join, Equals, Equals, Equals, Equals, Equals, op_Equality, op_Inequality, get_Chars, CopyTo, ToCharArray, ToCharArray, IsNullOrEmpty, GetHashCode, get_Length, Split, Split, Split, Split, Split, Split, Substring, Substring, Trim, Trim, TrimStart, TrimEnd, .ctor, .ctor, .ctor, .ctor, .ctor, .ctor, .ctor, .ctor, IsNormalized, IsNormalized, Normalize, Normalize, Compare, Compare, Compare, Compare, Compare, Compare, Compare, Compare, Compare, Compare, CompareTo, CompareTo, CompareOrdinal, CompareOrdinal, Contains, EndsWith, EndsWith, EndsWith, IndexOf, IndexOf, IndexOf, IndexOf, IndexOf, IndexOf, IndexOf, IndexOf, IndexOf, IndexOfAny, IndexOfAny, IndexOfAny, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOfAny, LastIndexOfAny, LastIndexOfAny, PadLeft, PadLeft, PadRight, PadRight, StartsWith, StartsWith, StartsWith, ToLower, ToLower, ToLowerInvariant, ToUpper, ToUpper, ToUpperInvariant, ToString, ToString, Clone, Insert, Replace, Replace, Remove, Remove, Format, Format, Format, Format, Format, Copy, Concat, Concat, Concat, Concat, Concat, Concat, Concat, Concat, Concat, Intern, IsInterned, GetTypeCode, GetEnumerator, .ctor, ToString, Equals, GetHashCode, GetType}"
GetProperties="{System.Char Chars, System.Int32 Length}"
IsPrimitive="True"
IsValueType="True">
IsClass="True"
IsPrimitive="True">
<GetElementType>null</GetElementType>
</DebugType>
</Type>
@ -614,6 +615,28 @@ namespace Debugger.Tests { @@ -614,6 +615,28 @@ namespace Debugger.Tests {
</Type>
</LocalVariable>
</Item>
<Item>
<LocalVariable
Name="s"
Type="System.String"
Value="abc">
<Type>
<DebugType
Attributes="AutoLayout, AnsiClass, Class, Public, Sealed, Serializable, BeforeFieldInit"
BaseType="System.Object"
FullName="System.String"
GetFields="{System.String Empty}"
GetInterfaces="{System.IComparable, System.ICloneable, System.IConvertible, System.IComparable`1[[System.String]], System.Collections.Generic.IEnumerable`1[[System.Char]], System.Collections.IEnumerable, System.IEquatable`1[[System.String]]}"
GetMembers="{System.String Empty, Join, Join, Equals, Equals, Equals, Equals, Equals, op_Equality, op_Inequality, get_Chars, CopyTo, ToCharArray, ToCharArray, IsNullOrEmpty, GetHashCode, get_Length, Split, Split, Split, Split, Split, Split, Substring, Substring, Trim, Trim, TrimStart, TrimEnd, .ctor, .ctor, .ctor, .ctor, .ctor, .ctor, .ctor, .ctor, IsNormalized, IsNormalized, Normalize, Normalize, Compare, Compare, Compare, Compare, Compare, Compare, Compare, Compare, Compare, Compare, CompareTo, CompareTo, CompareOrdinal, CompareOrdinal, Contains, EndsWith, EndsWith, EndsWith, IndexOf, IndexOf, IndexOf, IndexOf, IndexOf, IndexOf, IndexOf, IndexOf, IndexOf, IndexOfAny, IndexOfAny, IndexOfAny, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOfAny, LastIndexOfAny, LastIndexOfAny, PadLeft, PadLeft, PadRight, PadRight, StartsWith, StartsWith, StartsWith, ToLower, ToLower, ToLowerInvariant, ToUpper, ToUpper, ToUpperInvariant, ToString, ToString, Clone, Insert, Replace, Replace, Remove, Remove, Format, Format, Format, Format, Format, Copy, Concat, Concat, Concat, Concat, Concat, Concat, Concat, Concat, Concat, Intern, IsInterned, GetTypeCode, GetEnumerator, System.Char Chars, System.Int32 Length, .ctor, ToString, Equals, GetHashCode, GetType}"
GetMethods="{Join, Join, Equals, Equals, Equals, Equals, Equals, op_Equality, op_Inequality, get_Chars, CopyTo, ToCharArray, ToCharArray, IsNullOrEmpty, GetHashCode, get_Length, Split, Split, Split, Split, Split, Split, Substring, Substring, Trim, Trim, TrimStart, TrimEnd, .ctor, .ctor, .ctor, .ctor, .ctor, .ctor, .ctor, .ctor, IsNormalized, IsNormalized, Normalize, Normalize, Compare, Compare, Compare, Compare, Compare, Compare, Compare, Compare, Compare, Compare, CompareTo, CompareTo, CompareOrdinal, CompareOrdinal, Contains, EndsWith, EndsWith, EndsWith, IndexOf, IndexOf, IndexOf, IndexOf, IndexOf, IndexOf, IndexOf, IndexOf, IndexOf, IndexOfAny, IndexOfAny, IndexOfAny, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOf, LastIndexOfAny, LastIndexOfAny, LastIndexOfAny, PadLeft, PadLeft, PadRight, PadRight, StartsWith, StartsWith, StartsWith, ToLower, ToLower, ToLowerInvariant, ToUpper, ToUpper, ToUpperInvariant, ToString, ToString, Clone, Insert, Replace, Replace, Remove, Remove, Format, Format, Format, Format, Format, Copy, Concat, Concat, Concat, Concat, Concat, Concat, Concat, Concat, Concat, Intern, IsInterned, GetTypeCode, GetEnumerator, .ctor, ToString, Equals, GetHashCode, GetType}"
GetProperties="{System.Char Chars, System.Int32 Length}"
IsClass="True"
IsPrimitive="True">
<GetElementType>null</GetElementType>
</DebugType>
</Type>
</LocalVariable>
</Item>
<Item>
<LocalVariable
Name="obj"

104
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/ExpressionEvaluator.cs

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbeck<EFBFBD>" email="dsrbecky@gmail.com"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
@ -10,6 +10,45 @@ using System.Collections.Generic; @@ -10,6 +10,45 @@ using System.Collections.Generic;
namespace Debugger.Tests.TestPrograms
{
// TODO: Make nested
public class BaseClass
{
string name = "base name";
public string Name {
get { return name; }
}
public static string StaticValue = "base static value";
public string Foo(int i)
{
return "base Foo - int";
}
}
public class DerivedClass: BaseClass
{
string name = "derived name";
new public string Name {
get { return name; }
}
new public static string StaticValue = "derived static value";
new public string Foo(int i)
{
return "derived Foo - int";
}
public string Foo(string s)
{
return "derived Foo - string";
}
}
public class ExpressionEvaluator
{
public static void Main()
@ -25,6 +64,8 @@ namespace Debugger.Tests.TestPrograms @@ -25,6 +64,8 @@ namespace Debugger.Tests.TestPrograms
char[][] arrays = new char[][] {array, array2};
List<char> list = new List<char>(array);
DerivedClass myClass = new DerivedClass();
System.Diagnostics.Debugger.Break();
}
}
@ -32,6 +73,8 @@ namespace Debugger.Tests.TestPrograms @@ -32,6 +73,8 @@ namespace Debugger.Tests.TestPrograms
#if TEST_CODE
namespace Debugger.Tests {
using Debugger.MetaData;
using System.Reflection;
using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.Ast;
@ -56,6 +99,7 @@ namespace Debugger.Tests { @@ -56,6 +99,7 @@ namespace Debugger.Tests {
pi + ' ' + hi
(5 + 6) % (1 + 2)
3 % 2 == 1
15 & 255
15 && 255
b + 3 == i
@ -95,6 +139,24 @@ namespace Debugger.Tests { @@ -95,6 +139,24 @@ namespace Debugger.Tests {
Eval(line.Trim());
}
// Test member hiding / overloading
Value myClass = process.SelectedStackFrame.GetLocalVariableValue("myClass");
List<Expression> expressions = new List<Expression>();
foreach(MemberInfo memberInfo in myClass.Type.GetMembers(Debugger.MetaData.DebugType.BindingFlagsAll)) {
if (memberInfo.Name == typeof(object).Name) continue;
if (memberInfo.MemberType == MemberTypes.Field || memberInfo.MemberType == MemberTypes.Property)
expressions.Add(new IdentifierExpression("myClass").AppendMemberReference((IDebugMemberInfo)memberInfo));
}
expressions.Add(new IdentifierExpression("myClass").AppendMemberReference((DebugMethodInfo)((DebugType)myClass.Type.BaseType).GetMethod("Foo", new string[] { "i" }), new PrimitiveExpression(1)));
expressions.Add(new IdentifierExpression("myClass").AppendMemberReference((DebugMethodInfo)myClass.Type.GetMethod("Foo", new string[] { "i" }), new PrimitiveExpression(1)));
expressions.Add(new IdentifierExpression("myClass").AppendMemberReference((DebugMethodInfo)myClass.Type.GetMethod("Foo", new string[] { "s" }), new PrimitiveExpression("a")));
foreach(Expression expr in expressions) {
Eval(expr.PrettyPrint());
}
EndTest();
}
@ -129,7 +191,7 @@ namespace Debugger.Tests { @@ -129,7 +191,7 @@ namespace Debugger.Tests {
<ProcessStarted />
<ModuleLoaded>mscorlib.dll (No symbols)</ModuleLoaded>
<ModuleLoaded>ExpressionEvaluator.exe (Has symbols)</ModuleLoaded>
<DebuggingPaused>Break ExpressionEvaluator.cs:28,4-28,40</DebuggingPaused>
<DebuggingPaused>Break ExpressionEvaluator.cs:69,4-69,40</DebuggingPaused>
<Eval> </Eval>
<Eval> b = 1 </Eval>
<Eval> i = 4 </Eval>
@ -139,11 +201,12 @@ namespace Debugger.Tests { @@ -139,11 +201,12 @@ namespace Debugger.Tests {
<Eval> i + b = 5 </Eval>
<Eval> b + pi = 4.14000010490417 </Eval>
<Eval> pi + b = 4.14000010490417 </Eval>
<Eval> hi + pi = hi3.14 </Eval>
<Eval> pi + hi = 3.14hi </Eval>
<Eval> pi + " " + hi = 3.14 hi </Eval>
<Eval> hi + pi = "hi3.14" </Eval>
<Eval> pi + hi = "3.14hi" </Eval>
<Eval> pi + " " + hi = "3.14 hi" </Eval>
<Eval> </Eval>
<Eval> (5 + 6) % (1 + 2) = 2 </Eval>
<Eval> 3 % 2 == 1 = True </Eval>
<Eval> 15 &amp; 255 = 15 </Eval>
<Eval> 15 &amp;&amp; 255 = Error evaluating "15 &amp;&amp; 255": Unsupported operator for integers: LogicalAnd </Eval>
<Eval> b + 3 == i = True </Eval>
@ -151,19 +214,19 @@ namespace Debugger.Tests { @@ -151,19 +214,19 @@ namespace Debugger.Tests {
<Eval> true == true = True </Eval>
<Eval> true == false = False </Eval>
<Eval> </Eval>
<Eval> array = Char[] {H, e, l, l, o} </Eval>
<Eval> arrays = Char[][] {Char[] {H, e, l, l, o}, Char[] {w, o, r, l, d}} </Eval>
<Eval> array[1] = e </Eval>
<Eval> array[i] = o </Eval>
<Eval> array[i - 1] = l </Eval>
<Eval> list = List`1 {H, e, l, l, o} </Eval>
<Eval> list[1] = e </Eval>
<Eval> list[i] = o </Eval>
<Eval> hi[1] = i </Eval>
<Eval> "abcd"[2] = c </Eval>
<Eval> array = Char[] {'H', 'e', 'l', 'l', 'o'} </Eval>
<Eval> arrays = Char[][] {Char[] {'H', 'e', 'l', 'l', 'o'}, Char[] {'w', 'o', 'r', 'l', 'd'}} </Eval>
<Eval> array[1] = 'e' </Eval>
<Eval> array[i] = 'o' </Eval>
<Eval> array[i - 1] = 'l' </Eval>
<Eval> list = List`1 {'H', 'e', 'l', 'l', 'o'} </Eval>
<Eval> list[1] = 'e' </Eval>
<Eval> list[i] = 'o' </Eval>
<Eval> hi[1] = 'i' </Eval>
<Eval> "abcd"[2] = 'c' </Eval>
<Eval> </Eval>
<Eval> list.Add(42); list.Add(52);</Eval>
<Eval> list = List`1 {H, e, l, l, o, *, 4} </Eval>
<Eval> list = List`1 {'H', 'e', 'l', 'l', 'o', '*', '4'} </Eval>
<Eval> </Eval>
<Eval> i = 10 = 10 </Eval>
<Eval> -i = -10 </Eval>
@ -176,6 +239,15 @@ namespace Debugger.Tests { @@ -176,6 +239,15 @@ namespace Debugger.Tests {
<Eval> flag = True </Eval>
<Eval> !flag = False </Eval>
<Eval> </Eval>
<Eval> ((Debugger.Tests.TestPrograms.DerivedClass)(myClass)).name = "derived name" </Eval>
<Eval> Debugger.Tests.TestPrograms.DerivedClass.StaticValue = Error evaluating "Debugger.Tests.TestPrograms.DerivedClass.StaticValue": Identifier "Debugger" not found in this context </Eval>
<Eval> ((Debugger.Tests.TestPrograms.DerivedClass)(myClass)).Name = "derived name" </Eval>
<Eval> ((Debugger.Tests.TestPrograms.BaseClass)(myClass)).name = "base name" </Eval>
<Eval> Debugger.Tests.TestPrograms.BaseClass.StaticValue = Error evaluating "Debugger.Tests.TestPrograms.BaseClass.StaticValue": Identifier "Debugger" not found in this context </Eval>
<Eval> ((Debugger.Tests.TestPrograms.BaseClass)(myClass)).Name = "base name" </Eval>
<Eval> ((Debugger.Tests.TestPrograms.BaseClass)(myClass)).Foo((System.Int32)(1)) = "base Foo - int" </Eval>
<Eval> ((Debugger.Tests.TestPrograms.DerivedClass)(myClass)).Foo((System.Int32)(1)) = "derived Foo - int" </Eval>
<Eval> ((Debugger.Tests.TestPrograms.DerivedClass)(myClass)).Foo((System.String)("a")) = "derived Foo - string" </Eval>
<ProcessExited />
</Test>
</DebuggerTests>

356
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Expressions.cs

@ -1,356 +0,0 @@ @@ -1,356 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbeck<EFBFBD>" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System;
namespace Debugger.Tests.TestPrograms
{
public class BaseClass
{
string name = "base name";
public string Name {
get { return name; }
}
public string Value = "base value";
public string Foo(int i)
{
return "base-int";
}
}
public class TestClass: BaseClass
{
string name = "derived name";
new public string Name {
get { return name; }
}
new public string Value = "derived value";
string field = "field value";
string[] array = {"one", "two", "three"};
public static void Main()
{
new TestClass().Test("argValue");
}
public void Test(string arg)
{
int i = 0;
string[] array = {"one", "two", "three"};
string[,] array2 = {{"A","B"},{"C","D"}};
string BaseClass = "baseClassString";
System.Diagnostics.Debugger.Break();
}
public void Test(int arg)
{
}
public void Test(TestClass[] arg)
{
}
public new string Foo(int i)
{
return "deriv-int";
}
public string Foo(string s)
{
return "deriv-string";
}
}
}
#if TEST_CODE
namespace Debugger.Tests {
using ICSharpCode.NRefactory.Ast;
public partial class DebuggerTests
{
[NUnit.Framework.Test]
public void Expressions()
{
StartTest("Expressions.cs");
ObjectDump("Arguments", process.SelectedStackFrame.GetArgumentValues());
ObjectDump("LocalVariables", process.SelectedStackFrame.GetLocalVariableValues());
ObjectDump("this", process.SelectedStackFrame.GetThisValue().GetMemberValues());
ObjectDump("methods", process.SelectedStackFrame.MethodInfo.DeclaringType.GetMethods());
Value thisVal = process.SelectedStackFrame.GetThisValue().GetPermanentReference();
Expression baseMethod = new ThisReferenceExpression().AppendMemberReference(thisVal.Type.BaseType.GetMethod("Foo", "i"), new PrimitiveExpression(1));
Expression derivedMethod = new ThisReferenceExpression().AppendMemberReference(thisVal.Type.GetMethod("Foo", "i"), new PrimitiveExpression(1));
Expression overloadMethod = new ThisReferenceExpression().AppendMemberReference(thisVal.Type.GetMethod("Foo", "s"), new PrimitiveExpression("a"));
ObjectDump("BaseMethod", baseMethod.PrettyPrint());
ObjectDump("BaseMethod-Eval", baseMethod.Evaluate(process));
ObjectDump("HiddenMethod", derivedMethod.PrettyPrint());
ObjectDump("HiddenMethod-Eval", derivedMethod.Evaluate(process));
ObjectDump("OverloadMethod", overloadMethod.PrettyPrint());
ObjectDump("OverloadMethod-Eval", overloadMethod.Evaluate(process));
EndTest();
}
}
}
#endif
#if EXPECTED_OUTPUT
<?xml version="1.0" encoding="utf-8"?>
<DebuggerTests>
<Test
name="Expressions.cs">
<ProcessStarted />
<ModuleLoaded>mscorlib.dll (No symbols)</ModuleLoaded>
<ModuleLoaded>Expressions.exe (Has symbols)</ModuleLoaded>
<DebuggingPaused>Break Expressions.cs:53,4-53,40</DebuggingPaused>
<Arguments
Capacity="4"
Count="1">
<Item>
<Value
AsString="argValue"
IsReference="True"
PrimitiveValue="argValue"
Type="System.String" />
</Item>
</Arguments>
<LocalVariables
Capacity="8"
Count="5">
<Item>
<Value
AsString="0"
PrimitiveValue="0"
Type="System.Int32" />
</Item>
<Item>
<Value
ArrayDimensions="{3}"
ArrayLength="3"
ArrayRank="1"
AsString="{System.String[]}"
IsReference="True"
PrimitiveValue="{Exception: Value is not a primitive type}"
Type="System.String[]" />
</Item>
<Item>
<Value
ArrayDimensions="{2, 2}"
ArrayLength="4"
ArrayRank="2"
AsString="{System.String[,]}"
IsReference="True"
PrimitiveValue="{Exception: Value is not a primitive type}"
Type="System.String[,]" />
</Item>
<Item>
<Value
AsString="baseClassString"
IsReference="True"
PrimitiveValue="baseClassString"
Type="System.String" />
</Item>
<Item>
<Value
AsString="{Debugger.Tests.TestPrograms.TestClass}"
IsReference="True"
PrimitiveValue="{Exception: Value is not a primitive type}"
Type="Debugger.Tests.TestPrograms.TestClass" />
</Item>
</LocalVariables>
<this>
<Item>
<Value
AsString="derived name"
IsReference="True"
PrimitiveValue="derived name"
Type="System.String" />
</Item>
<Item>
<Value
AsString="derived value"
IsReference="True"
PrimitiveValue="derived value"
Type="System.String" />
</Item>
<Item>
<Value
AsString="field value"
IsReference="True"
PrimitiveValue="field value"
Type="System.String" />
</Item>
<Item>
<Value
ArrayDimensions="{3}"
ArrayLength="3"
ArrayRank="1"
AsString="{System.String[]}"
IsReference="True"
PrimitiveValue="{Exception: Value is not a primitive type}"
Type="System.String[]" />
</Item>
<Item>
<Value
AsString="base name"
IsReference="True"
PrimitiveValue="base name"
Type="System.String" />
</Item>
<Item>
<Value
AsString="base value"
IsReference="True"
PrimitiveValue="base value"
Type="System.String" />
</Item>
<Item>
<Value
AsString="derived name"
IsReference="True"
PrimitiveValue="derived name"
Type="System.String" />
</Item>
<Item>
<Value
AsString="base name"
IsReference="True"
PrimitiveValue="base name"
Type="System.String" />
</Item>
</this>
<methods
Capacity="8"
Count="8">
<Item>
<MethodInfo
DeclaringType="Debugger.Tests.TestPrograms.TestClass"
FullName="Debugger.Tests.TestPrograms.TestClass.get_Name"
IsPublic="True"
IsSpecialName="True"
LocalVariableNames="{this}"
Module="Expressions.exe"
Name="get_Name"
ReturnType="System.String"
StepOver="True" />
</Item>
<Item>
<MethodInfo
DeclaringType="Debugger.Tests.TestPrograms.TestClass"
FullName="Debugger.Tests.TestPrograms.TestClass.Main"
IsPublic="True"
IsStatic="True"
Module="Expressions.exe"
Name="Main" />
</Item>
<Item>
<MethodInfo
DeclaringType="Debugger.Tests.TestPrograms.TestClass"
FullName="Debugger.Tests.TestPrograms.TestClass.Test"
IsPublic="True"
LocalVariableNames="{array, array2, BaseClass, i, this}"
Module="Expressions.exe"
Name="Test"
ParameterCount="1"
ParameterTypes="{System.String}" />
</Item>
<Item>
<MethodInfo
DeclaringType="Debugger.Tests.TestPrograms.TestClass"
FullName="Debugger.Tests.TestPrograms.TestClass.Test"
IsPublic="True"
LocalVariableNames="{this}"
Module="Expressions.exe"
Name="Test"
ParameterCount="1"
ParameterTypes="{System.Int32}" />
</Item>
<Item>
<MethodInfo
DeclaringType="Debugger.Tests.TestPrograms.TestClass"
FullName="Debugger.Tests.TestPrograms.TestClass.Test"
IsPublic="True"
LocalVariableNames="{this}"
Module="Expressions.exe"
Name="Test"
ParameterCount="1"
ParameterTypes="{Debugger.Tests.TestPrograms.TestClass[]}" />
</Item>
<Item>
<MethodInfo
DeclaringType="Debugger.Tests.TestPrograms.TestClass"
FullName="Debugger.Tests.TestPrograms.TestClass.Foo"
IsPublic="True"
LocalVariableNames="{this}"
Module="Expressions.exe"
Name="Foo"
ParameterCount="1"
ParameterTypes="{System.Int32}"
ReturnType="System.String" />
</Item>
<Item>
<MethodInfo
DeclaringType="Debugger.Tests.TestPrograms.TestClass"
FullName="Debugger.Tests.TestPrograms.TestClass.Foo"
IsPublic="True"
LocalVariableNames="{this}"
Module="Expressions.exe"
Name="Foo"
ParameterCount="1"
ParameterTypes="{System.String}"
ReturnType="System.String" />
</Item>
<Item>
<MethodInfo
DeclaringType="Debugger.Tests.TestPrograms.TestClass"
FullName="Debugger.Tests.TestPrograms.TestClass..ctor"
IsPublic="True"
IsSpecialName="True"
LocalVariableNames="{this}"
Module="Expressions.exe"
Name=".ctor" />
</Item>
</methods>
<BaseMethod>((Debugger.Tests.TestPrograms.BaseClass)(this)).Foo((System.Int32)(1))</BaseMethod>
<BaseMethod-Eval>
<Value
AsString="base-int"
IsReference="True"
PrimitiveValue="base-int"
Type="System.String" />
</BaseMethod-Eval>
<HiddenMethod>((Debugger.Tests.TestPrograms.TestClass)(this)).Foo((System.Int32)(1))</HiddenMethod>
<HiddenMethod-Eval>
<Value
AsString="deriv-int"
IsReference="True"
PrimitiveValue="deriv-int"
Type="System.String" />
</HiddenMethod-Eval>
<OverloadMethod>((Debugger.Tests.TestPrograms.TestClass)(this)).Foo((System.String)("a"))</OverloadMethod>
<OverloadMethod-Eval>
<Value
AsString="deriv-string"
IsReference="True"
PrimitiveValue="deriv-string"
Type="System.String" />
</OverloadMethod-Eval>
<ProcessExited />
</Test>
</DebuggerTests>
#endif // EXPECTED_OUTPUT
Loading…
Cancel
Save