Merge pull request #1659 from alexanderkyte/stringbuilder-referencesource
[mono.git] / mcs / class / Mono.Debugger.Soft / Test / dtest.cs
index d7aaacd3383596d24cc0c4a8e385f717fcadaa6c..0076f9f340b531355ce8f3f88f657c67a4c9f896 100644 (file)
@@ -420,6 +420,10 @@ public class DebuggerTests
                e = step_out ();
                assert_location (e, "single_stepping");
 
+               // Step into next line
+               e = step_into ();
+               assert_location (e, "single_stepping");
+
                // Step into ss3_2 ()
                e = step_into ();
                assert_location (e, "ss3_2");
@@ -1134,6 +1138,10 @@ public class DebuggerTests
                Assert.IsTrue (t.IsEnum);
                Assert.AreEqual ("Int32", t.EnumUnderlyingType.Name);
 
+               // TypedReferences
+               t = frame.Method.GetParameters ()[11].ParameterType;
+               Assert.AreEqual ("TypedReference", t.Name);
+
                // properties
                t = frame.Method.GetParameters ()[7].ParameterType;
 
@@ -1425,6 +1433,10 @@ public class DebuggerTests
                AssertValue (2, s ["i"]);
                AssertValue ("S2", s ["s"]);
 
+               // typedbyref
+               var typedref = frame.GetArgument (2) as StructMirror;
+               Assert.IsTrue (typedref is StructMirror);
+
                // Argument checking
                s = frame.GetArgument (0) as StructMirror;
                AssertThrows<ArgumentException> (delegate () {
@@ -2142,6 +2154,11 @@ public class DebuggerTests
                v = this_obj.InvokeMethod (e.Thread, m, null, InvokeOptions.Virtual);
                AssertValue ("V2", v);
 
+               // virtual call on static method
+               m = t.GetMethod ("invoke_static_pass_ref");
+               v = t.InvokeMethod (e.Thread, m, new Value [] { vm.RootDomain.CreateString ("ABC") }, InvokeOptions.Virtual);
+               AssertValue ("ABC", v);
+
 #if NET_4_5
                // instance
                m = t.GetMethod ("invoke_pass_ref");
@@ -2912,6 +2929,13 @@ public class DebuggerTests
                AssertThrows<Exception> (delegate {
                                d_method.DeclaringType.GetValue (d_method.DeclaringType.GetField ("static_i"));
                        });
+
+               // Check that .Domain is accessible for stack frames with native transitions
+               e = run_until ("called_from_invoke");
+               ThreadMirror.NativeTransitions = true;
+               foreach (var f in e.Thread.GetFrames ()) {
+                       var dom = f.Domain;
+               }
        }
 
        [Test]
@@ -3536,10 +3560,10 @@ public class DebuggerTests
 
                e.Thread.SetIP (next_loc);
 
-               /* Check that i = 5; j = 5; was skipped */
+               /* Check that i ++; j = 5; was skipped */
                bevent = run_until ("set_ip_2");
                var f = bevent.Thread.GetFrames ()[1];
-               AssertValue (1, f.GetValue (f.Method.GetLocal ("i")));
+               AssertValue (2, f.GetValue (f.Method.GetLocal ("i")));
                AssertValue (0, f.GetValue (f.Method.GetLocal ("j")));
 
                // Error handling
@@ -3552,6 +3576,30 @@ public class DebuggerTests
                        });
        }
 
+       [Test]
+       public void SetIPSingleStep () {
+               // Check that single stepping after set-ip steps from the new ip
+               var bevent = run_until ("set_ip_1");
+
+               var invalid_loc = bevent.Thread.GetFrames ()[0].Location;
+
+               var req = create_step (bevent);
+               req.Size = StepSize.Line;
+               var e = step_out ();
+               req.Disable ();
+               var frames = e.Thread.GetFrames ();
+               var locs = frames [0].Method.Locations;
+               var prev_loc = locs.First (l => (l.LineNumber == frames [0].Location.LineNumber - 3));
+               AssertValue (2, frames [0].GetValue (frames [0].Method.GetLocal ("i")));
+
+               // Set back the ip to the first i ++; line
+               e.Thread.SetIP (prev_loc);
+
+               e = step_over ();
+               var f = e.Thread.GetFrames ()[0];
+               AssertValue (3, f.GetValue (f.Method.GetLocal ("i")));
+       }
+
        [Test]
        public void NewInstanceNoCtor () {
                var bevent = run_until ("Main");
@@ -3561,6 +3609,28 @@ public class DebuggerTests
                Assert.IsTrue (obj is ObjectMirror);
                Assert.AreEqual ("AStruct", (obj as ObjectMirror).Type.Name);
        }
+
+       [Test]
+       public void StaticCtorFilterInCctor () {
+               // Check that single stepping when in a cctor only ignores
+               // other cctors, not the current one
+               var bevent = run_until ("step_filters");
+
+               var assembly = entry_point.DeclaringType.Assembly;
+               var type = assembly.GetType ("Tests/ClassWithCctor");
+               var cctor = type.GetMethod (".cctor");
+               vm.SetBreakpoint (cctor, 0);
+
+               vm.Resume ();
+               var e = vm.GetNextEvent ();
+               Assert.IsTrue (e is BreakpointEvent);
+
+               var req = create_step (e);
+               req.Filter = StepFilter.StaticCtor;
+               e = step_into ();
+               // Make sure we are still in the cctor
+               Assert.AreEqual (".cctor", e.Thread.GetFrames ()[0].Location.Method.Name);
+       }
 }
 
 }