Exemplo n.º 1
0
static void test_throw_in_catch(void) {
  int volatile catch = 0, first = 0;

try {
  JD_SV(a, "first");
    jd_throw("Throw from %V block", a);
  }
  catch (e) {
    try {
      JD_SV(a, "catch");
      jd_throw("Throw from %V block", a);
    }
    catch (e) {
      jdt_is_string(jd_rv(e, "$.message"),
                    "Throw from catch block", "got throw catch");
      catch ++;
  }
  jdt_is_string(jd_rv(e, "$.message"),
                "Throw from first block", "got first catch");
    first++;
  }
Exemplo n.º 2
0
int jdt_throws(void (*func)(void *), void *ctx, const char *want, const char *msg, ...) {
  va_list ap;
  int rc = 0;

  scope {
    JD_VAR(caught);
    JD_SV(vwant, want);

    try {
      func(ctx);
    }
    catch(e) {
      jd_assign(caught, e);
    }

    va_start(ap, msg);
    rc = _is(jd_get_ks(caught, "message", 0), vwant, msg, ap);
    va_end(ap);
  }
  return rc;
}