1 /* -*- Mode: C; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the Mozilla Public License Version 2.0.
7 // See license.mkd for licensing and copyright information.
8 // -------------------------------------------------------------------------*/
14 #include "sjme/except.h"
17 static sjme_errorCode
nestedExcept(sjme_test
* test
,
18 volatile sjme_exceptTrace
* trace
)
22 SJME_EXCEPT_WITH(trace
):
23 SJME_EXCEPT_TOSS(SJME_ERROR_TOP_NOT_LONG
);
25 sjme_unit_fail(test
, "Nested point should not be reached.");
29 sjme_unit_equalI(test
, exceptTraceE_sjme
, SJME_ERROR_TOP_NOT_LONG
,
30 "Nested error code was not set?");
32 /* Success otherwise. */
33 SJME_EXCEPT_DONE_RETURN_ERROR();
37 * Tests nested exception handling.
41 SJME_TEST_DECLARE(testExceptFailNested
)
44 volatile sjme_exceptTrace
* trace
;
50 exceptTraceE_sjme
= 666;
51 SJME_EXCEPT_WITH(trace
):
52 if (sjme_error_is(nestedExcept(test
, trace
)))
53 SJME_EXCEPT_TOSS_SAME();
55 /* Should hopefully not be reached. */
56 sjme_unit_fail(test
, "Should not be reached here?");
60 sjme_unit_equalI(test
, exceptTraceE_sjme
, SJME_ERROR_TOP_NOT_LONG
,
61 "Error code was not set?");
63 /* Success otherwise. */
64 SJME_EXCEPT_DONE(SJME_TEST_RESULT_PASS
);