From ca46e425162833dfe907cdb34dd876739922db80 Mon Sep 17 00:00:00 2001 From: Frederik Seiffert Date: Thu, 23 Dec 2021 08:32:51 +0100 Subject: [PATCH] Add test for unexpected exception hook --- Test/CMakeLists.txt | 1 + Test/UnexpectedException.m | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 Test/UnexpectedException.m diff --git a/Test/CMakeLists.txt b/Test/CMakeLists.txt index 8ae5e95..dc4cbbc 100644 --- a/Test/CMakeLists.txt +++ b/Test/CMakeLists.txt @@ -34,6 +34,7 @@ set(TESTS ResurrectInDealloc_arc.m RuntimeTest.m SuperMethodMissing.m + UnexpectedException.m WeakBlock_arc.m WeakRefLoad.m WeakReferences_arc.m diff --git a/Test/UnexpectedException.m b/Test/UnexpectedException.m new file mode 100644 index 0000000..bf82da2 --- /dev/null +++ b/Test/UnexpectedException.m @@ -0,0 +1,20 @@ +#include "Test.h" +#include "../objc/hooks.h" + +#include + +id exceptionObj = @"Exception"; + +void UncaughtExceptionHandler(id exception) +{ + assert(exception == exceptionObj); + exit(0); +} + +int main(void) +{ + _objc_unexpected_exception = UncaughtExceptionHandler; + @throw exceptionObj; + assert(0 && "should not be reached!"); + return -1; +}