|
| 1 | +// |
| 2 | +// AdvancedEvaluationTests.cs |
| 3 | +// |
| 4 | +// Author: |
| 5 | +// David Karlaš <[email protected]> |
| 6 | +// |
| 7 | +// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com) |
| 8 | +// |
| 9 | +// Permission is hereby granted, free of charge, to any person obtaining a copy |
| 10 | +// of this software and associated documentation files (the "Software"), to deal |
| 11 | +// in the Software without restriction, including without limitation the rights |
| 12 | +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 13 | +// copies of the Software, and to permit persons to whom the Software is |
| 14 | +// furnished to do so, subject to the following conditions: |
| 15 | +// |
| 16 | +// The above copyright notice and this permission notice shall be included in |
| 17 | +// all copies or substantial portions of the Software. |
| 18 | +// |
| 19 | +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 20 | +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 21 | +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 22 | +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 23 | +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 24 | +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 25 | +// THE SOFTWARE. |
| 26 | +using System; |
| 27 | +using NUnit.Framework; |
| 28 | + |
| 29 | +namespace Mono.Debugging.Tests |
| 30 | +{ |
| 31 | + namespace Soft |
| 32 | + { |
| 33 | + [TestFixture] |
| 34 | + public class SdbAdvancedEvaluationAllowTargetInvokesTests : AdvancedEvaluationTests |
| 35 | + { |
| 36 | + public SdbAdvancedEvaluationAllowTargetInvokesTests () : base ("Mono.Debugger.Soft", true) |
| 37 | + { |
| 38 | + } |
| 39 | + } |
| 40 | + |
| 41 | + [TestFixture] |
| 42 | + public class SdbAdvancedEvaluationNoTargetInvokesTests : AdvancedEvaluationTests |
| 43 | + { |
| 44 | + public SdbAdvancedEvaluationNoTargetInvokesTests () : base ("Mono.Debugger.Soft", false) |
| 45 | + { |
| 46 | + } |
| 47 | + } |
| 48 | + } |
| 49 | + |
| 50 | + namespace Win32 |
| 51 | + { |
| 52 | + [TestFixture] |
| 53 | + [Platform(Include = "Win")] |
| 54 | + public class CorAdvancedEvaluationAllowTargetInvokesTests : AdvancedEvaluationTests |
| 55 | + { |
| 56 | + public CorAdvancedEvaluationAllowTargetInvokesTests () : base ("MonoDevelop.Debugger.Win32", true) |
| 57 | + { |
| 58 | + } |
| 59 | + } |
| 60 | + |
| 61 | + [TestFixture] |
| 62 | + [Platform(Include = "Win")] |
| 63 | + public class CorAdvancedEvaluationNoTargetInvokesTests : AdvancedEvaluationTests |
| 64 | + { |
| 65 | + public CorAdvancedEvaluationNoTargetInvokesTests () : base ("MonoDevelop.Debugger.Win32", false) |
| 66 | + { |
| 67 | + } |
| 68 | + } |
| 69 | + } |
| 70 | + |
| 71 | + [TestFixture] |
| 72 | + public abstract class AdvancedEvaluationTests : DebugTests |
| 73 | + { |
| 74 | + protected AdvancedEvaluationTests (string de, bool allowTargetInvokes) : base (de) |
| 75 | + { |
| 76 | + AllowTargetInvokes = allowTargetInvokes; |
| 77 | + } |
| 78 | + |
| 79 | + [TestFixtureSetUp] |
| 80 | + public override void SetUp () |
| 81 | + { |
| 82 | + base.SetUp (); |
| 83 | + Start ("AdvancedEvaluation"); |
| 84 | + } |
| 85 | + |
| 86 | + [Test] |
| 87 | + public void Bug24998 () |
| 88 | + { |
| 89 | + InitializeTest (); |
| 90 | + AddBreakpoint ("cc622137-a162-4b91-a85c-88241e68c3ea"); |
| 91 | + StartTest ("Bug24998Test"); |
| 92 | + CheckPosition ("cc622137-a162-4b91-a85c-88241e68c3ea"); |
| 93 | + var val = Eval ("someField"); |
| 94 | + Assert.AreEqual ("\"das\"", val.Value); |
| 95 | + Assert.AreEqual ("string", val.TypeName); |
| 96 | + |
| 97 | + val = Eval ("someVariable"); |
| 98 | + Assert.AreEqual ("System.Collections.ArrayList", val.TypeName); |
| 99 | + var children = val.GetAllChildrenSync (); |
| 100 | + Assert.AreEqual (2, children.Length); |
| 101 | + Assert.AreEqual ("[0]", children [0].ChildSelector); |
| 102 | + Assert.AreEqual ("1", children [0].Value); |
| 103 | + Assert.AreEqual ("int", children [0].TypeName); |
| 104 | + |
| 105 | + val = Eval ("action"); |
| 106 | + Assert.AreEqual ("System.Action", val.TypeName); |
| 107 | + } |
| 108 | + |
| 109 | + |
| 110 | + [Test] |
| 111 | + public void YieldMethodTest () |
| 112 | + { |
| 113 | + InitializeTest (); |
| 114 | + AddBreakpoint ("0b1212f8-9035-43dc-bf01-73efd078d680"); |
| 115 | + StartTest ("YieldMethodTest"); |
| 116 | + CheckPosition ("0b1212f8-9035-43dc-bf01-73efd078d680"); |
| 117 | + |
| 118 | + var val = Eval ("someVariable"); |
| 119 | + Assert.AreEqual ("System.Collections.ArrayList", val.TypeName); |
| 120 | + Assert.AreEqual (1, val.GetAllChildrenSync ().Length); |
| 121 | + |
| 122 | + AddBreakpoint ("e96b28bb-59bf-445d-b71f-316726ba4c52"); |
| 123 | + Continue ("e96b28bb-59bf-445d-b71f-316726ba4c52"); |
| 124 | + |
| 125 | + val = Eval ("someField"); |
| 126 | + Assert.AreEqual ("\"das1\"", val.Value); |
| 127 | + Assert.AreEqual ("string", val.TypeName); |
| 128 | + val = Eval ("someVariable"); |
| 129 | + Assert.AreEqual ("System.Collections.ArrayList", val.TypeName); |
| 130 | + Assert.AreEqual (2, val.GetAllChildrenSync ().Length); |
| 131 | + |
| 132 | + AddBreakpoint ("760feb92-176a-43d7-b5c9-116c4a3c6a6c"); |
| 133 | + Continue ("760feb92-176a-43d7-b5c9-116c4a3c6a6c"); |
| 134 | + |
| 135 | + val = Eval ("someField"); |
| 136 | + Assert.AreEqual ("\"das2\"", val.Value); |
| 137 | + Assert.AreEqual ("string", val.TypeName); |
| 138 | + val = Eval ("someVariable"); |
| 139 | + Assert.AreEqual ("System.Collections.ArrayList", val.TypeName); |
| 140 | + Assert.AreEqual (3, val.GetAllChildrenSync ().Length); |
| 141 | + |
| 142 | + AddBreakpoint ("a9a9aa9d-6b8b-4724-9741-2a3e1fb435e8"); |
| 143 | + Continue ("a9a9aa9d-6b8b-4724-9741-2a3e1fb435e8"); |
| 144 | + |
| 145 | + val = Eval ("someField"); |
| 146 | + Assert.AreEqual ("\"das2\"", val.Value); |
| 147 | + Assert.AreEqual ("string", val.TypeName); |
| 148 | + val = Eval ("someVariable"); |
| 149 | + Assert.AreEqual ("System.Collections.ArrayList", val.TypeName); |
| 150 | + Assert.AreEqual (3, val.GetAllChildrenSync ().Length); |
| 151 | + |
| 152 | + } |
| 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 | + } |
| 183 | + |
| 184 | + [Test] |
| 185 | + public void MethodWithTypeGenericArgsEval () |
| 186 | + { |
| 187 | + InitializeTest (); |
| 188 | + AddBreakpoint ("ba6350e5-7149-4cc2-a4cf-8a54c635eb38"); |
| 189 | + StartTest ("MethodWithTypeGenericArgsEval"); |
| 190 | + CheckPosition ("ba6350e5-7149-4cc2-a4cf-8a54c635eb38"); |
| 191 | + |
| 192 | + var baseMethodEval = Eval ("genericClass.BaseMethodWithClassTArg (wrappedA)"); |
| 193 | + Assert.NotNull (baseMethodEval); |
| 194 | + Assert.AreEqual ("{Wrapper(wrappedA)}", baseMethodEval.Value); |
| 195 | + |
| 196 | + var thisMethodEval = Eval ("genericClass.RetMethodWithClassTArg (a)"); |
| 197 | + Assert.NotNull (thisMethodEval); |
| 198 | + Assert.AreEqual ("{Just A}", thisMethodEval.Value); |
| 199 | + } |
| 200 | + |
| 201 | + |
| 202 | + } |
| 203 | +} |
| 204 | + |
0 commit comments