Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Adding more tests.
  • Loading branch information
thaystg authored and github-actions committed Sep 9, 2021
commit 9d00648bdba2f96f441a37a4822bf2d3cd0d9a0e
25 changes: 14 additions & 11 deletions src/mono/wasm/debugger/DebuggerTestSuite/ExceptionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,11 @@ await CheckValue(pause_location["data"], JObject.FromObject(new
CheckString(exception_members, "message", "not implemented uncaught");
}

[Fact]
public async Task ExceptionTestAllWithReload()
[Theory]
[InlineData("[debugger-test] DebuggerTests.ExceptionTestsClassDefault:TestExceptions", "System.Exception", 76)]
[InlineData("[debugger-test] DebuggerTests.ExceptionTestsClass:TestExceptions", "DebuggerTests.CustomException", 28)]
public async Task ExceptionTestAllWithReload(string entry_method_name, string class_name, int line_number)
{
string entry_method_name = "[debugger-test] DebuggerTests.ExceptionTestsClass:TestExceptions";
var debugger_test_loc = "dotnet://debugger-test.dll/debugger-exception-test.cs";

await SetPauseOnException("all");
Expand All @@ -255,7 +256,7 @@ public async Task ExceptionTestAllWithReload()
i++;
}


var eval_expr = "window.setTimeout(function() { invoke_static_method (" +
$"'{entry_method_name}'" +
"); }, 1);";
Expand All @@ -270,29 +271,31 @@ await CheckValue(pause_location["data"], JObject.FromObject(new
{
type = "object",
subtype = "error",
className = "DebuggerTests.CustomException",
uncaught = false
className = class_name,
uncaught = false,
description = "not implemented caught"
}), "exception0.data");

var exception_members = await GetProperties(pause_location["data"]["objectId"]?.Value<string>());
CheckString(exception_members, "message", "not implemented caught");
CheckString(exception_members, "_message", "not implemented caught");

pause_location = await WaitForManagedException(null);
AssertEqual("run", pause_location["callFrames"]?[0]?["functionName"]?.Value<string>(), "pause1");

//stop in the uncaught exception
CheckLocation(debugger_test_loc, 28, 16, scripts, pause_location["callFrames"][0]["location"]);
CheckLocation(debugger_test_loc, line_number, 16, scripts, pause_location["callFrames"][0]["location"]);

await CheckValue(pause_location["data"], JObject.FromObject(new
{
type = "object",
subtype = "error",
className = "DebuggerTests.CustomException",
uncaught = true
className = class_name,
uncaught = true,
description = "not implemented uncaught"
}), "exception1.data");

exception_members = await GetProperties(pause_location["data"]["objectId"]?.Value<string>());
CheckString(exception_members, "message", "not implemented uncaught");
CheckString(exception_members, "_message", "not implemented uncaught");
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,40 @@ public CustomException(string message)
this.message = message;
}
}

public class ExceptionTestsClassDefault
{
public class TestCaughtException
{
public void run()
{
try
{
throw new Exception("not implemented caught");
}
catch
{
Console.WriteLine("caught exception");
}
}
}

public class TestUncaughtException
{
public void run()
{
throw new Exception("not implemented uncaught");
}
}

public static void TestExceptions()
{
TestCaughtException f = new TestCaughtException();
f.run();

TestUncaughtException g = new TestUncaughtException();
g.run();
}

}
}