wasmer/lib/emscripten/emtests/test_longjmp_exc.c
2019-01-10 21:38:10 -08:00

36 lines
728 B
C

/*
* Copyright 2016 The Emscripten Authors. All rights reserved.
* Emscripten is available under two separate licenses, the MIT license and the
* University of Illinois/NCSA Open Source License. Both these licenses can be
* found in the LICENSE file.
*/
#include <stdlib.h>
#include <stdio.h>
#include <setjmp.h>
#include <emscripten.h>
jmp_buf abortframe;
void dostuff(int a) {
printf("pre\n");
if (a != 42)
emscripten_run_script(
"waka_waka()"); // this should fail, and never reach "never"
printf("never\n");
if (a == 100) {
longjmp(abortframe, -1);
}
if (setjmp(abortframe)) {
printf("got 100");
}
}
int main(int argc, char **argv) {
dostuff(argc);
exit(1);
return 1;
}