summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
d2e20fe)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@1544
48e7efb5-ca39-0410-a469-
dd3cf9ba447f
ts_test_check(TS_CTX, "basic nested control flow");
n = 1;
ts_test_check(TS_CTX, "basic nested control flow");
n = 1;
if (n != 1)
ts_test_fail(TS_CTX, "M1: n=%d (!= 1)", n);
n++;
if (n != 1)
ts_test_fail(TS_CTX, "M1: n=%d (!= 1)", n);
n++;
if (n != 2)
ts_test_fail(TS_CTX, "M2: n=%d (!= 2)", n);
n++;
if (n != 2)
ts_test_fail(TS_CTX, "M2: n=%d (!= 2)", n);
n++;
- xbt_throw(0,0,"something");
- }
- xbt_catch (ex) {
+ THROW(0,0,"something");
+ } CATCH (ex) {
if (n != 3)
ts_test_fail(TS_CTX, "M3: n=%d (!= 1)", n);
n++;
if (n != 3)
ts_test_fail(TS_CTX, "M3: n=%d (!= 1)", n);
n++;
}
ts_test_fail(TS_CTX, "MX: n=%d (expected: not reached)", n);
}
}
ts_test_fail(TS_CTX, "MX: n=%d (expected: not reached)", n);
}
if (n != 4)
ts_test_fail(TS_CTX, "M4: n=%d (!= 4)", n);
n++;
if (n != 4)
ts_test_fail(TS_CTX, "M4: n=%d (!= 4)", n);
n++;
- xbt_try {
- xbt_throw(1, 2, "toto");
- }
- xbt_catch (ex) {
+ TRY {
+ THROW(1, 2, "toto");
+ } CATCH(ex) {
ts_test_check(TS_CTX, "exception value passing");
if (ex.category != 1)
ts_test_fail(TS_CTX, "category=%d (!= 1)", ex.category);
ts_test_check(TS_CTX, "exception value passing");
if (ex.category != 1)
ts_test_fail(TS_CTX, "category=%d (!= 1)", ex.category);
volatile int v1, v2;
r1 = r2 = v1 = v2 = 1234;
volatile int v1, v2;
r1 = r2 = v1 = v2 = 1234;
- xbt_throw(0, 0, 0);
- }
- xbt_catch (ex) {
+ THROW(0, 0, 0);
+ } CATCH(ex) {
ts_test_check(TS_CTX, "variable preservation");
if (r1 != 1234)
ts_test_fail(TS_CTX, "r1=%d (!= 1234)", r1);
ts_test_check(TS_CTX, "variable preservation");
if (r1 != 1234)
ts_test_fail(TS_CTX, "r1=%d (!= 1234)", r1);
volatile int i3 = 0;
ts_test_check(TS_CTX, "exception deferring");
volatile int i3 = 0;
ts_test_check(TS_CTX, "exception deferring");
ts_test_fail(TS_CTX, "unexpected deferring scope");
ts_test_fail(TS_CTX, "unexpected deferring scope");
- xbt_try {
- xbt_defer {
- if (!xbt_deferring)
+ TRY {
+ DEFER {
+ if (!IS_DEFERRED)
ts_test_fail(TS_CTX, "unexpected non-deferring scope");
ts_test_fail(TS_CTX, "unexpected non-deferring scope");
- xbt_throw(4711, 0, NULL);
}
ts_test_fail(TS_CTX, "unexpected not occurred deferred throwing");
}
}
ts_test_fail(TS_CTX, "unexpected not occurred deferred throwing");
}
if (ex.category != 4711)
ts_test_fail(TS_CTX, "caught exception with value %d, expected 4711", ex.value);
}
if (ex.category != 4711)
ts_test_fail(TS_CTX, "caught exception with value %d, expected 4711", ex.value);
}
ex_t ex;
ts_test_check(TS_CTX, "exception shielding");
ex_t ex;
ts_test_check(TS_CTX, "exception shielding");
ts_test_fail(TS_CTX, "unexpected shielding scope");
ts_test_fail(TS_CTX, "unexpected shielding scope");
ts_test_fail(TS_CTX, "unexpected catching scope");
ts_test_fail(TS_CTX, "unexpected catching scope");
- xbt_try {
- xbt_shield {
- if (!xbt_shielding)
+ TRY {
+ SHIELD {
+ if (!IS_SHIELDED)
ts_test_fail(TS_CTX, "unexpected non-shielding scope");
ts_test_fail(TS_CTX, "unexpected non-shielding scope");
ts_test_fail(TS_CTX, "unexpected shielding scope");
ts_test_fail(TS_CTX, "unexpected shielding scope");
ts_test_fail(TS_CTX, "unexpected non-catching scope");
ts_test_fail(TS_CTX, "unexpected non-catching scope");
ts_test_fail(TS_CTX, "unexpected exception catched");
ts_test_fail(TS_CTX, "unexpected exception catched");
ts_test_fail(TS_CTX, "unexpected catching scope");
}
ts_test_fail(TS_CTX, "unexpected catching scope");
}
ts_test_fail(TS_CTX, "unexpected catching scope");
}
ts_test_fail(TS_CTX, "unexpected catching scope");
}
- xbt_throw(1, 2, "blah");
- }
- xbt_cleanup {
+ THROW(1, 2, "blah");
+ } CLEANUP {
if (v1 != 5678)
ts_test_fail(TS_CTX, "v1 = %d (!= 5678)", v1);
c = 1;
if (v1 != 5678)
ts_test_fail(TS_CTX, "v1 = %d (!= 5678)", v1);
c = 1;
if (v1 != 5678)
ts_test_fail(TS_CTX, "v1 = %d (!= 5678)", v1);
if (!(ex.category == 1 && ex.value == 2 && !strcmp(ex.msg,"blah")))
if (v1 != 5678)
ts_test_fail(TS_CTX, "v1 = %d (!= 5678)", v1);
if (!(ex.category == 1 && ex.value == 2 && !strcmp(ex.msg,"blah")))
ex_t ex;
/* BAD_EXAMPLE */
ex_t ex;
/* BAD_EXAMPLE */
char *cp1, *cp2, *cp3;
cp1 = mallocex(SMALLAMOUNT);
char *cp1, *cp2, *cp3;
cp1 = mallocex(SMALLAMOUNT);
cp3 = mallocex(SMALLAMOUNT);
strcpy(cp1, "foo");
strcpy(cp2, "bar");
cp3 = mallocex(SMALLAMOUNT);
strcpy(cp1, "foo");
strcpy(cp2, "bar");
if (cp3 != NULL) free(cp3);
if (cp2 != NULL) free(cp2);
if (cp1 != NULL) free(cp1);
if (cp3 != NULL) free(cp3);
if (cp2 != NULL) free(cp2);
if (cp1 != NULL) free(cp1);
}
/* end_of_bad_example */
}
}
/* end_of_bad_example */
}
char * volatile /*03*/ cp1 = NULL /*02*/;
char * volatile /*03*/ cp2 = NULL /*02*/;
char * volatile /*03*/ cp3 = NULL /*02*/;
char * volatile /*03*/ cp1 = NULL /*02*/;
char * volatile /*03*/ cp2 = NULL /*02*/;
char * volatile /*03*/ cp3 = NULL /*02*/;
cp1 = mallocex(SMALLAMOUNT);
globalcontext->first = cp1;
cp1 = NULL /*05 give away*/;
cp1 = mallocex(SMALLAMOUNT);
globalcontext->first = cp1;
cp1 = NULL /*05 give away*/;
cp3 = mallocex(SMALLAMOUNT);
strcpy(cp1, "foo");
strcpy(cp2, "bar");
cp3 = mallocex(SMALLAMOUNT);
strcpy(cp1, "foo");
strcpy(cp2, "bar");
printf("cp3=%s", cp3 == NULL /*02*/ ? "" : cp3);
if (cp3 != NULL)
free(cp3);
if (cp2 != NULL)
free(cp2);
/*05 cp1 was given away */
printf("cp3=%s", cp3 == NULL /*02*/ ? "" : cp3);
if (cp3 != NULL)
free(cp3);
if (cp2 != NULL)
free(cp2);
/*05 cp1 was given away */
/*05 global context untouched */
/*05 global context untouched */
}
}
/* end_of_good_example */
}
}
/* end_of_good_example */