diff --git a/src/libraries/System.Runtime/tests/System/ExceptionTests.cs b/src/libraries/System.Runtime/tests/System/ExceptionTests.cs index 8c01f9a280c5a3..bcd7cb305898b4 100644 --- a/src/libraries/System.Runtime/tests/System/ExceptionTests.cs +++ b/src/libraries/System.Runtime/tests/System/ExceptionTests.cs @@ -61,7 +61,7 @@ public static void Exception_GetBaseException() } [Fact] - public static void Exception_TargetSite_Jit() + public static void Exception_TargetSite() { bool caught = false; @@ -78,6 +78,32 @@ public static void Exception_TargetSite_Jit() Assert.True(caught); } + + static void RethrowException() + { + try + { + ThrowException(); + } + catch + { + throw; + } + } + + [Fact] + public static void Exception_TargetSite_OtherMethod() + { + Exception ex = Assert.ThrowsAny(() => ThrowException()); + Assert.Equal(nameof(ThrowException), ex.TargetSite.Name); + } + + [Fact] + public static void Exception_TargetSite_Rethrow() + { + Exception ex = Assert.ThrowsAny(() => RethrowException()); + Assert.Equal(nameof(ThrowException), ex.TargetSite.Name); + } [Fact] [ActiveIssue("https://github.com/mono/mono/issues/15140", TestRuntimes.Mono)]