Browse Source

Fixing/updating debugger unit tests:

DynamicCode,
ExpressionEvaluatorVisitor_Tests,
StackFrame_Tests,
Value_Tests
newNRvisualizers
David Srbecký 13 years ago
parent
commit
5d802a226d
  1. 13
      src/AddIns/Debugger/Debugger.Core/Eval.cs
  2. 2
      src/AddIns/Debugger/Debugger.Core/Value.cs
  3. 10
      src/AddIns/Debugger/Debugger.Tests/DebuggerTestsBase.cs
  4. 2
      src/AddIns/Debugger/Debugger.Tests/Tests/DynamicCode.cs
  5. 2
      src/AddIns/Debugger/Debugger.Tests/Tests/ExpressionEvaluatorVisitor_Tests.cs

13
src/AddIns/Debugger/Debugger.Core/Eval.cs

@ -224,20 +224,17 @@ namespace Debugger
throw new GetValueException("'this' is null"); throw new GetValueException("'this' is null");
if (thisValue.IsNull) if (thisValue.IsNull)
throw new GetValueException("Null reference"); throw new GetValueException("Null reference");
// if (!(thisValue.IsObject)) // eg Can evaluate on array
if (!thisValue.Type.GetDefinition().IsDerivedFrom(method.DeclaringType.GetDefinition())) {
throw new GetValueException(
"Can not evaluate because the object is not of proper type. " +
"Expected: " + method.DeclaringType.FullName + " Seen: " + thisValue.Type.FullName
);
}
corArgs.Add(thisValue.CorValue); corArgs.Add(thisValue.CorValue);
} }
for(int i = 0; i < args.Length; i++) { for(int i = 0; i < args.Length; i++) {
Value arg = args[i]; Value arg = args[i];
IType paramType = method.Parameters[i].Type; IType paramType = method.Parameters[i].Type;
if (!arg.IsNull && !arg.Type.GetDefinition().IsDerivedFrom(paramType.GetDefinition().GetDefinition())) if (!arg.IsNull &&
arg.Type.GetDefinition() != null &&
paramType.GetDefinition() != null &&
!arg.Type.GetDefinition().IsDerivedFrom(paramType.GetDefinition())) {
throw new GetValueException("Inncorrect parameter type. Expected " + paramType.ToString()); throw new GetValueException("Inncorrect parameter type. Expected " + paramType.ToString());
}
// It is importatnt to pass the parameter in the correct form (boxed/unboxed) // It is importatnt to pass the parameter in the correct form (boxed/unboxed)
if (paramType.IsReferenceType == true) { if (paramType.IsReferenceType == true) {
if (!arg.IsReference) if (!arg.IsReference)

2
src/AddIns/Debugger/Debugger.Core/Value.cs

@ -402,7 +402,7 @@ namespace Debugger
if (objectInstance.IsNull) if (objectInstance.IsNull)
throw new GetValueException("Null reference"); throw new GetValueException("Null reference");
// Array.Length can be called // Array.Length can be called
if (objectInstance.Type.IsKnownType(KnownTypeCode.Array)) if (objectInstance.Type.Kind == TypeKind.Array)
return; return;
if (objectInstance.Type.GetDefinition() == null || !objectInstance.Type.GetDefinition().IsDerivedFrom(memberInfo.DeclaringType.GetDefinition())) if (objectInstance.Type.GetDefinition() == null || !objectInstance.Type.GetDefinition().IsDerivedFrom(memberInfo.DeclaringType.GetDefinition()))
throw new GetValueException("Object is not of type " + memberInfo.DeclaringType.FullName); throw new GetValueException("Object is not of type " + memberInfo.DeclaringType.FullName);

10
src/AddIns/Debugger/Debugger.Tests/DebuggerTestsBase.cs

@ -7,11 +7,12 @@ using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;
using System.Linq;
using System.Reflection; using System.Reflection;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text; using System.Text;
using System.Xml; using System.Xml;
using ICSharpCode.NRefactory.TypeSystem;
using Microsoft.CSharp; using Microsoft.CSharp;
using NUnit.Framework; using NUnit.Framework;
@ -271,7 +272,7 @@ namespace Debugger.Tests
class LocalVariable class LocalVariable
{ {
public string Name { get; set; } public string Name { get; set; }
public Type Type { get; set; } public IType Type { get; set; }
public Value Value { get; set; } public Value Value { get; set; }
} }
@ -281,12 +282,11 @@ namespace Debugger.Tests
} }
public void DumpLocalVariables(string msg) public void DumpLocalVariables(string msg)
{/* {
ObjectDump( ObjectDump(
msg, msg,
this.CurrentStackFrame.MethodInfo.GetLocalVariables(this.CurrentStackFrame.IP).Select(v => new LocalVariable() { Name = v.Name, Type = v.LocalType, Value = v.GetValue(this.CurrentStackFrame)}) this.CurrentStackFrame.GetLocalVariables(this.CurrentStackFrame.IP).Select(v => new LocalVariable() { Name = v.Name, Type = v.Type, Value = v.GetValue(this.CurrentStackFrame)})
); );
*/
} }
List<string> expandProperties; List<string> expandProperties;

2
src/AddIns/Debugger/Debugger.Tests/Tests/DynamicCode.cs

@ -51,7 +51,7 @@ namespace Debugger.Tests {
public partial class DebuggerTests public partial class DebuggerTests
{ {
[NUnit.Framework.Test] [NUnit.Framework.Test, NUnit.Framework.Ignore("We can not load in-memory assemblies with Cecil (yet)")]
public void DynamicCode() public void DynamicCode()
{ {
StartTest(); StartTest();

2
src/AddIns/Debugger/Debugger.Tests/Tests/ExpressionEvaluatorVisitor_Tests.cs

@ -297,7 +297,7 @@ namespace Debugger.Tests
AssertEval("DBBool.Null || DBBool.False", "DBBool.Null"); AssertEval("DBBool.Null || DBBool.False", "DBBool.Null");
AssertEval("DBBool.False || DBBool.False", "DBBool.False"); AssertEval("DBBool.False || DBBool.False", "DBBool.False");
AssertEval("array", "Char[] {'H', 'e', 'l', 'l', 'o'}"); AssertEval("array", "Char[] {'H', 'e', 'l', 'l', 'o'}");
AssertEval("array.ToList()", "List<Char> {'H', 'e', 'l', 'l', 'o'}"); AssertEval("array.ToList()", "List {'H', 'e', 'l', 'l', 'o'}");
EndTest(false); EndTest(false);
} }

Loading…
Cancel
Save