diff options
-rw-r--r-- | tests/core/test_exception_2.in | 26 | ||||
-rw-r--r-- | tests/core/test_exception_2.out | 1 | ||||
-rw-r--r-- | tests/test_core.py | 28 |
3 files changed, 30 insertions, 25 deletions
diff --git a/tests/core/test_exception_2.in b/tests/core/test_exception_2.in new file mode 100644 index 00000000..5a9efce5 --- /dev/null +++ b/tests/core/test_exception_2.in @@ -0,0 +1,26 @@ + + #include <stdexcept> + #include <stdio.h> + + typedef void (*FuncPtr)(); + + void ThrowException() + { + throw std::runtime_error("catch me!"); + } + + FuncPtr ptr = ThrowException; + + int main() + { + try + { + ptr(); + } + catch(...) + { + printf("Exception caught successfully!\n"); + } + return 0; + } +
\ No newline at end of file diff --git a/tests/core/test_exception_2.out b/tests/core/test_exception_2.out new file mode 100644 index 00000000..aa89c67d --- /dev/null +++ b/tests/core/test_exception_2.out @@ -0,0 +1 @@ +Exception caught successfully!
\ No newline at end of file diff --git a/tests/test_core.py b/tests/test_core.py index 17c1dffe..b1d8f0c8 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -1244,33 +1244,11 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co def test_exception_2(self): if self.emcc_args is None: return self.skip('need emcc to add in libcxx properly') Settings.DISABLE_EXCEPTION_CATCHING = 0 - src = r''' - #include <stdexcept> - #include <stdio.h> - - typedef void (*FuncPtr)(); - void ThrowException() - { - throw std::runtime_error("catch me!"); - } - - FuncPtr ptr = ThrowException; + test_path = path_from_root('tests', 'core', 'test_exception_2') + src, output = (test_path + s for s in ('.in', '.out')) - int main() - { - try - { - ptr(); - } - catch(...) - { - printf("Exception caught successfully!\n"); - } - return 0; - } - ''' - self.do_run(src, 'Exception caught successfully!') + self.do_run_from_file(src, output) def test_white_list_exception(self): Settings.DISABLE_EXCEPTION_CATCHING = 2 |