Skip to content

Commit fcbf91d

Browse files
authored
Added tests for static DIM. (dotnet#70138)
1 parent 0dbb28f commit fcbf91d

File tree

3 files changed

+52
-7
lines changed

3 files changed

+52
-7
lines changed

src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -588,10 +588,10 @@ await SendCommandAndCheck(null, "Debugger.resume",
588588
[InlineData(true, "RunNonUserCode", "DebuggerAttribute", 1, 867, 8)]
589589
[InlineData(false, "RunStepThroughWithNonUserCode", "DebuggerAttribute", 1, 933, 8)]
590590
[InlineData(true, "RunStepThroughWithNonUserCode", "DebuggerAttribute", 1, 933, 8)]
591-
[InlineData(false, "EvaluateStepThroughAttr", "DefaultInterfaceMethod", 2, 1091, 4)]
592-
[InlineData(true, "EvaluateStepThroughAttr", "DefaultInterfaceMethod", 2, 1091, 4)]
593-
[InlineData(false, "EvaluateNonUserCodeAttr", "DefaultInterfaceMethod", 2, 1048, 4, "NonUserCodeDefaultMethod")]
594-
[InlineData(true, "EvaluateNonUserCodeAttr", "DefaultInterfaceMethod", 2, 1097, 4)]
591+
[InlineData(false, "EvaluateStepThroughAttr", "DefaultInterfaceMethod", 2, 1108, 4)]
592+
[InlineData(true, "EvaluateStepThroughAttr", "DefaultInterfaceMethod", 2, 1108, 4)]
593+
[InlineData(false, "EvaluateNonUserCodeAttr", "DefaultInterfaceMethod", 2, 1065, 4, "NonUserCodeDefaultMethod")]
594+
[InlineData(true, "EvaluateNonUserCodeAttr", "DefaultInterfaceMethod", 2, 1114, 4)]
595595
public async Task StepThroughOrNonUserCodeAttributeStepInNoBp(bool justMyCodeEnabled, string evalFunName, string evalClassName, int bpLine, int line, int col, string funcName="")
596596
{
597597
var bp_init = await SetBreakpointInMethod("debugger-test.dll", evalClassName, evalFunName, bpLine);
@@ -821,9 +821,11 @@ await EvaluateAndCheck(
821821
}
822822

823823
[ConditionalTheory(nameof(RunningOnChrome))]
824-
[InlineData("IDefaultInterface", "DefaultMethod", "Evaluate", 1070, 1001, 999, 1003)]
825-
[InlineData("IExtendIDefaultInterface", "IDefaultInterface.DefaultMethodToOverride", "Evaluate", 1071, 1030, 1028, 1032)]
826-
[InlineData("IDefaultInterface", "DefaultMethodAsync", "EvaluateAsync", 37, 1014, 1012, 1016, true, "Start<IDefaultInterface/<DefaultMethodAsync>d__2>")]
824+
[InlineData("IDefaultInterface", "DefaultMethod", "Evaluate", 1087, 1003, 1001, 1005)]
825+
[InlineData("IExtendIDefaultInterface", "IDefaultInterface.DefaultMethodToOverride", "Evaluate", 1088, 1047, 1045, 1049)]
826+
[InlineData("IDefaultInterface", "DefaultMethodAsync", "EvaluateAsync", 37, 1016, 1014, 1018, true, "Start<IDefaultInterface/<DefaultMethodAsync>d__3>")]
827+
[InlineData("IDefaultInterface", "DefaultMethodStatic", "EvaluateStatic", 1124, 1022, 1020, 1024)]
828+
[InlineData("IDefaultInterface", "DefaultMethodAsyncStatic", "EvaluateAsyncStatic", 37, 1031, 1029, 1033, true, "Start<IDefaultInterface/<DefaultMethodAsyncStatic>d__5>")]
827829
public async Task BreakInDefaultInterfaceMethod(
828830
string dimClassName, string dimName, string entryMethod, int evaluateAsPrevFrameLine, int dimAsPrevFrameLine, int functionLocationLine, int functionEndLine, bool isAsync = false, string asyncPrevFrameInDim = "")
829831
{

src/mono/wasm/debugger/DebuggerTestSuite/EvaluateOnCallFrameTests.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,5 +1294,21 @@ await EvaluateOnCallFrameAndCheck(id,
12941294
("this", TObject("DIMClass")),
12951295
("this.dimClassMember", TNumber(123)));
12961296
});
1297+
1298+
[Theory]
1299+
[InlineData("DefaultMethodStatic", "IDefaultInterface", "EvaluateStatic")]
1300+
[InlineData("DefaultMethodAsyncStatic", "IDefaultInterface", "EvaluateAsyncStatic", true)]
1301+
public async Task EvaluateLocalsInDefaultInterfaceMethodStatic(string pauseMethod, string methodInterface, string entryMethod, bool isAsync = false) =>
1302+
await CheckInspectLocalsAtBreakpointSite(
1303+
methodInterface, pauseMethod, 2, isAsync ? "MoveNext" : pauseMethod,
1304+
$"window.setTimeout(function() {{ invoke_static_method ('[debugger-test] DefaultInterfaceMethod:{entryMethod}'); }})",
1305+
wait_for_event_fn: async (pause_location) =>
1306+
{
1307+
var id = pause_location["callFrames"][0]["callFrameId"].Value<string>();
1308+
await EvaluateOnCallFrameAndCheck(id,
1309+
("localString", TString($"{pauseMethod}()")),
1310+
("IDefaultInterface.defaultInterfaceMember", TString("defaultInterfaceMember")) //without interface name: "defaultInterfaceMember" fails; Issue #70135
1311+
);
1312+
});
12971313
}
12981314
}

src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -996,6 +996,8 @@ public static void RunMethod(string className, string methodName)
996996
#region Default Interface Method
997997
public interface IDefaultInterface
998998
{
999+
public static string defaultInterfaceMember = "defaultInterfaceMember";
1000+
9991001
string DefaultMethod()
10001002
{
10011003
string localString = "DefaultMethod()";
@@ -1015,6 +1017,21 @@ async System.Threading.Tasks.Task DefaultMethodAsync()
10151017
DefaultInterfaceMethod.MethodForCallingFromDIM();
10161018
await System.Threading.Tasks.Task.FromResult(0);
10171019
}
1020+
static string DefaultMethodStatic()
1021+
{
1022+
string localString = "DefaultMethodStatic()";
1023+
DefaultInterfaceMethod.MethodForCallingFromDIM();
1024+
return $"{localString} from IDefaultInterface";
1025+
}
1026+
1027+
// cannot override the static method of the interface - skipping
1028+
1029+
static async System.Threading.Tasks.Task DefaultMethodAsyncStatic()
1030+
{
1031+
string localString = "DefaultMethodAsyncStatic()";
1032+
DefaultInterfaceMethod.MethodForCallingFromDIM();
1033+
await System.Threading.Tasks.Task.FromResult(0);
1034+
}
10181035
}
10191036

10201037
public interface IExtendIDefaultInterface : IDefaultInterface
@@ -1103,6 +1120,16 @@ public static void EvaluateStepperBoundaryAttr()
11031120
extendDefaultInter.NonUserCodeDefaultMethod(extendDefaultInter.BoundaryBp);
11041121
}
11051122

1123+
public static void EvaluateStatic()
1124+
{
1125+
IExtendIDefaultInterface.DefaultMethodStatic();
1126+
}
1127+
1128+
public static async void EvaluateAsyncStatic()
1129+
{
1130+
await IExtendIDefaultInterface.DefaultMethodAsyncStatic();
1131+
}
1132+
11061133
public static void MethodForCallingFromDIM()
11071134
{
11081135
string text = "a place for pausing and inspecting DIM";

0 commit comments

Comments
 (0)