Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wasm][debugger][tests] Update tests to track the harness changes #2

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
444 changes: 198 additions & 246 deletions src/mono/wasm/debugger/DebuggerTestSuite/ArrayTests.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,7 @@ namespace DebuggerTests
{
public class BadHarnessInitTests : DebuggerTestBase
{
internal Inspector insp;
protected Dictionary<string, string> scripts;

public BadHarnessInitTests(string driver = "debugger-driver.html") : base(driver)
{
insp = new Inspector();
scripts = SubscribeToScripts(insp);
}
public override async Task InitializeAsync() => await Task.CompletedTask;

[Fact]
public async Task InvalidInitCommands()
Expand Down
405 changes: 180 additions & 225 deletions src/mono/wasm/debugger/DebuggerTestSuite/CallFunctionOnTests.cs

Large diffs are not rendered by default.

49 changes: 20 additions & 29 deletions src/mono/wasm/debugger/DebuggerTestSuite/DateTimeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,30 @@ public class DateTimeList : DebuggerTestBase
[InlineData("de-DE", "dddd, d. MMMM yyyy HH:mm:ss", "dddd, d. MMMM yyyy", "HH:mm:ss", "dd.MM.yyyy", "HH:mm")]
public async Task CheckDateTimeLocale(string locale, string fdtp, string ldp, string ltp, string sdp, string stp)
{
var insp = new Inspector();
var scripts = SubscribeToScripts(insp);
var debugger_test_loc = "dotnet://debugger-test.dll/debugger-datetime-test.cs";

await Ready();
await insp.Ready(async (cli, token) =>
{
ctx = new DebugTestContext(cli, insp, token, scripts);
var debugger_test_loc = "dotnet://debugger-test.dll/debugger-datetime-test.cs";
await SetBreakpointInMethod("debugger-test", "DebuggerTests.DateTimeTest", "LocaleTest", 15);

await SetBreakpointInMethod("debugger-test", "DebuggerTests.DateTimeTest", "LocaleTest", 15);
var pause_location = await EvaluateAndCheck(
"window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.DateTimeTest:LocaleTest'," +
$"'{locale}'); }}, 1);",
debugger_test_loc, 25, 12, "LocaleTest",
locals_fn: async (locals) =>
{
DateTimeFormatInfo dtfi = CultureInfo.GetCultureInfo(locale).DateTimeFormat;
CultureInfo.CurrentCulture = new CultureInfo(locale, false);

var pause_location = await EvaluateAndCheck(
"window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.DateTimeTest:LocaleTest'," +
$"'{locale}'); }}, 1);",
debugger_test_loc, 25, 12, "LocaleTest",
locals_fn: async (locals) =>
await CheckProps(locals, new
{
DateTimeFormatInfo dtfi = CultureInfo.GetCultureInfo(locale).DateTimeFormat;
CultureInfo.CurrentCulture = new CultureInfo(locale, false);

await CheckProps(locals, new
{
fdtp = TString(fdtp),
ldp = TString(ldp),
ltp = TString(ltp),
sdp = TString(sdp),
stp = TString(stp),
dt = TDateTime(new DateTime(2020, 1, 2, 3, 4, 5))
}, "locals", num_fields: 8);
}
);

});
fdtp = TString(fdtp),
ldp = TString(ldp),
ltp = TString(ltp),
sdp = TString(sdp),
stp = TString(stp),
dt = TDateTime(new DateTime(2020, 1, 2, 3, 4, 5))
}, "locals", num_fields: 8);
}
);
}

}
Expand Down
199 changes: 97 additions & 102 deletions src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestBase.cs

Large diffs are not rendered by default.

199 changes: 95 additions & 104 deletions src/mono/wasm/debugger/DebuggerTestSuite/EvaluateOnCallFrameTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,26 @@ public async Task EvaluateTypeInstanceMembers(string prefix, int bias, string ty
var dateTime = new DateTime(2010, 9, 8, 7, 6, 5 + bias);
var DTProp = dateTime.AddMinutes(10);

foreach (var pad in new[] { String.Empty, " " })
{
var padded_prefix = pad + prefix;
await EvaluateOnCallFrameAndCheck(id,
($"{padded_prefix}a", TNumber(4)),

// fields
($"{padded_prefix}dateTime.TimeOfDay", TValueType("System.TimeSpan", dateTime.TimeOfDay.ToString())),
($"{padded_prefix}dateTime", TDateTime(dateTime)),
($"{padded_prefix}dateTime.TimeOfDay.Minutes", TNumber(dateTime.TimeOfDay.Minutes)),

// properties
($"{padded_prefix}DTProp.TimeOfDay.Minutes", TNumber(DTProp.TimeOfDay.Minutes)),
($"{padded_prefix}DTProp", TDateTime(DTProp)),
($"{padded_prefix}DTProp.TimeOfDay", TValueType("System.TimeSpan", DTProp.TimeOfDay.ToString())),

($"{padded_prefix}IntProp", TNumber(9)),
($"{padded_prefix}NullIfAIsNotZero", TObject("DebuggerTests.EvaluateTestsClassWithProperties", is_null: true))
);
}
foreach (var pad in new[] { String.Empty, " " })
{
var padded_prefix = pad + prefix;
await EvaluateOnCallFrameAndCheck(id,
($"{padded_prefix}a", TNumber(4)),

// fields
($"{padded_prefix}dateTime.TimeOfDay", TValueType("System.TimeSpan", dateTime.TimeOfDay.ToString())),
($"{padded_prefix}dateTime", TDateTime(dateTime)),
($"{padded_prefix}dateTime.TimeOfDay.Minutes", TNumber(dateTime.TimeOfDay.Minutes)),

// properties
($"{padded_prefix}DTProp.TimeOfDay.Minutes", TNumber(DTProp.TimeOfDay.Minutes)),
($"{padded_prefix}DTProp", TDateTime(DTProp)),
($"{padded_prefix}DTProp.TimeOfDay", TValueType("System.TimeSpan", DTProp.TimeOfDay.ToString())),

($"{padded_prefix}IntProp", TNumber(9)),
($"{padded_prefix}NullIfAIsNotZero", TObject("DebuggerTests.EvaluateTestsClassWithProperties", is_null: true))
);
}
});

[Theory]
Expand Down Expand Up @@ -145,13 +145,13 @@ public async Task EvaluateLocalsAsync() => await CheckInspectLocalsAtBreakpointS
{
var id = pause_location["callFrames"][0]["callFrameId"].Value<string>();

// sc_arg
{
// sc_arg
{
var (sc_arg, _) = await EvaluateOnCallFrame(id, "sc_arg");
await CheckValue(sc_arg, TObject("DebuggerTests.SimpleClass"), nameof(sc_arg));

// Check that we did get the correct object
var sc_arg_props = await GetProperties(sc_arg["objectId"]?.Value<string>());
// Check that we did get the correct object
var sc_arg_props = await GetProperties(sc_arg["objectId"]?.Value<string>());
await CheckProps(sc_arg_props, new
{
X = TNumber(10),
Expand All @@ -167,8 +167,8 @@ await EvaluateOnCallFrameAndCheck(id,
("sc_arg.Id + (sc_arg.X==10 ? \"_is_ten\" : \"_not_ten\")", TString($"sc#Id_is_ten")));
}

// local_gs
{
// local_gs
{
var (local_gs, _) = await EvaluateOnCallFrame(id, "local_gs");
await CheckValue(local_gs, TValueType("DebuggerTests.SimpleGenericStruct<int>"), nameof(local_gs));

Expand Down Expand Up @@ -221,28 +221,28 @@ public async Task InheritedAndPrivateMembersInAClass(string prefix)
{
var id = pause_location["callFrames"][0]["callFrameId"].Value<string>();

foreach(var pad in new [] { String.Empty, " "})
{
var padded_prefix = pad + prefix;
await EvaluateOnCallFrameAndCheck(id,
// overridden
($"{padded_prefix}FirstName + \"_foo\"", TString("DerivedClass#FirstName_foo")),
($"{padded_prefix}DateTimeForOverride.Date.Year", TNumber(2190)),
($"{padded_prefix}DateTimeForOverride.Date.Year - 10", TNumber(2180)),
($"\"foo_\" + {padded_prefix}StringPropertyForOverrideWithAutoProperty", TString("foo_DerivedClass#StringPropertyForOverrideWithAutoProperty")),

// private
($"{padded_prefix}_stringField + \"_foo\"", TString("DerivedClass#_stringField_foo")),
($"{padded_prefix}_stringField", TString("DerivedClass#_stringField")),
($"{padded_prefix}_dateTime.Second + 4", TNumber(7)),
($"{padded_prefix}_DTProp.Second + 4", TNumber(13)),

// inherited public
($"\"foo_\" + {padded_prefix}Base_AutoStringProperty", TString("foo_base#Base_AutoStringProperty")),
// inherited private
($"{padded_prefix}_base_dateTime.Date.Year - 10", TNumber(2124))
);
}
foreach (var pad in new[] { String.Empty, " " })
{
var padded_prefix = pad + prefix;
await EvaluateOnCallFrameAndCheck(id,
// overridden
($"{padded_prefix}FirstName + \"_foo\"", TString("DerivedClass#FirstName_foo")),
($"{padded_prefix}DateTimeForOverride.Date.Year", TNumber(2190)),
($"{padded_prefix}DateTimeForOverride.Date.Year - 10", TNumber(2180)),
($"\"foo_\" + {padded_prefix}StringPropertyForOverrideWithAutoProperty", TString("foo_DerivedClass#StringPropertyForOverrideWithAutoProperty")),

// private
($"{padded_prefix}_stringField + \"_foo\"", TString("DerivedClass#_stringField_foo")),
($"{padded_prefix}_stringField", TString("DerivedClass#_stringField")),
($"{padded_prefix}_dateTime.Second + 4", TNumber(7)),
($"{padded_prefix}_DTProp.Second + 4", TNumber(13)),

// inherited public
($"\"foo_\" + {padded_prefix}Base_AutoStringProperty", TString("foo_base#Base_AutoStringProperty")),
// inherited private
($"{padded_prefix}_base_dateTime.Date.Year - 10", TNumber(2124))
);
}
});

[Fact]
Expand Down Expand Up @@ -322,8 +322,8 @@ public async Task EvaluateOnPreviousFrames(string type_name, bool is_valuetype)
var dt_local = new DateTime(2020, 3, 4, 5, 6, 7);
var dt_this = new DateTime(2010, 9, 8, 7, 6, 5);

// At EvaluateShadow
{
// At EvaluateShadow
{
var id0 = pause_location["callFrames"][0]["callFrameId"].Value<string>();
await EvaluateOnCallFrameAndCheck(id0,
("dateTime", TDateTime(dt_local)),
Expand All @@ -339,38 +339,38 @@ await EvaluateOnCallFrameFail(id1,
("dateTime", "ReferenceError"),
("this.dateTime", "ReferenceError"));

// obj available only on the -1 frame
await EvaluateOnCallFrameAndCheck(id1, ("obj.IntProp", TNumber(7)));
// obj available only on the -1 frame
await EvaluateOnCallFrameAndCheck(id1, ("obj.IntProp", TNumber(7)));
}

await SetBreakpointInMethod("debugger-test.dll", type_name, "SomeMethod", 1);
pause_location = await SendCommandAndCheck(null, "Debugger.resume", null, 0, 0, "SomeMethod");

// At SomeMethod
// At SomeMethod

// TODO: change types also.. so, that `this` is different!
// TODO: change types also.. so, that `this` is different!

// Check frame0
{
// Check frame0
{
var id0 = pause_location["callFrames"][0]["callFrameId"].Value<string>();

// 'me' and 'dateTime' are reversed in this method
await EvaluateOnCallFrameAndCheck(id0,
("dateTime", is_valuetype ? TValueType(type_name) : TObject(type_name)),
("this.dateTime", TDateTime(dt_this)),
("me", TDateTime(dt_local)),
// 'me' and 'dateTime' are reversed in this method
await EvaluateOnCallFrameAndCheck(id0,
("dateTime", is_valuetype ? TValueType(type_name) : TObject(type_name)),
("this.dateTime", TDateTime(dt_this)),
("me", TDateTime(dt_local)),

// local variable shadows field, but isn't "live" yet
("DTProp", TString(null)),
// local variable shadows field, but isn't "live" yet
("DTProp", TString(null)),

// access field via `this.`
("this.DTProp", TDateTime(dt_this.AddMinutes(10))));
// access field via `this.`
("this.DTProp", TDateTime(dt_this.AddMinutes(10))));

await EvaluateOnCallFrameFail(id0, ("obj", "ReferenceError"));
}

// check frame1
{
// check frame1
{
var id1 = pause_location["callFrames"][1]["callFrameId"].Value<string>();

await EvaluateOnCallFrameAndCheck(id1,
Expand All @@ -388,15 +388,15 @@ await EvaluateOnCallFrameAndCheck(id1,
await EvaluateOnCallFrameFail(id1, ("obj", "ReferenceError"));
}

// check frame2
{
// check frame2
{
var id2 = pause_location["callFrames"][2]["callFrameId"].Value<string>();

// Only obj should be available
await EvaluateOnCallFrameFail(id2,
("dateTime", "ReferenceError"),
("this.dateTime", "ReferenceError"),
("me", "ReferenceError"));
// Only obj should be available
await EvaluateOnCallFrameFail(id2,
("dateTime", "ReferenceError"),
("this.dateTime", "ReferenceError"),
("me", "ReferenceError"));

await EvaluateOnCallFrameAndCheck(id2, ("obj", is_valuetype ? TValueType(type_name) : TObject(type_name)));
}
Expand All @@ -405,32 +405,23 @@ await EvaluateOnCallFrameFail(id2,
[Fact]
public async Task JSEvaluate()
{
var insp = new Inspector();
//Collect events
var scripts = SubscribeToScripts(insp);

var bp_loc = "/other.js";
var line = 76;
var col = 1;

await Ready();
await insp.Ready(async (cli, token) =>
{
ctx = new DebugTestContext(cli, insp, token, scripts);
await SetBreakpoint(bp_loc, line, col);
await SetBreakpoint(bp_loc, line, col);

var eval_expr = "window.setTimeout(function() { eval_call_on_frame_test (); }, 1)";
var result = await ctx.cli.SendCommand("Runtime.evaluate", JObject.FromObject(new { expression = eval_expr }), ctx.token);
var pause_location = await ctx.insp.WaitFor(Inspector.PAUSE);
var eval_expr = "window.setTimeout(function() { eval_call_on_frame_test (); }, 1)";
var result = await cli.SendCommand("Runtime.evaluate", JObject.FromObject(new { expression = eval_expr }), token);
var pause_location = await insp.WaitFor(Inspector.PAUSE);

var id = pause_location["callFrames"][0]["callFrameId"].Value<string>();
var id = pause_location["callFrames"][0]["callFrameId"].Value<string>();

await EvaluateOnCallFrameFail(id,
("me.foo", null),
("obj.foo.bar", null));
await EvaluateOnCallFrameFail(id,
("me.foo", null),
("obj.foo.bar", null));

await EvaluateOnCallFrame(id, "obj.foo", expect_ok: true);
});
await EvaluateOnCallFrame(id, "obj.foo", expect_ok: true);
}

[Fact]
Expand All @@ -441,23 +432,23 @@ public async Task NegativeTestsInInstanceMethod() => await CheckInspectLocalsAtB
{
var id = pause_location["callFrames"][0]["callFrameId"].Value<string>();

// Use '.' on a primitive member
await EvaluateOnCallFrameFail(id,
//BUG: TODO:
//("a)", "CompilationError"),
// Use '.' on a primitive member
await EvaluateOnCallFrameFail(id,
//BUG: TODO:
//("a)", "CompilationError"),

("this.a.", "ReferenceError"),
("a.", "ReferenceError"),
("this.a.", "ReferenceError"),
("a.", "ReferenceError"),

("this..a", "CompilationError"),
(".a.", "ReferenceError"),
("this..a", "CompilationError"),
(".a.", "ReferenceError"),

("me.foo", "ReferenceError"),
("me.foo", "ReferenceError"),

("this.a + non_existant", "ReferenceError"),
("this.a + non_existant", "ReferenceError"),

("this.NullIfAIsNotZero.foo", "ReferenceError"),
("NullIfAIsNotZero.foo", "ReferenceError"));
("this.NullIfAIsNotZero.foo", "ReferenceError"),
("NullIfAIsNotZero.foo", "ReferenceError"));
});

[Fact]
Expand Down
Loading