Make all NanoCoat types closeable; Make unrefing closeable the default.
[SquirrelJME.git] / nanocoat / tests / testExceptFailNested.c
blob6d7b19524d1d03c4f81f8cc45f44bc4191ed600a
1 /* -*- Mode: C; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
3 // SquirrelJME
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 // -------------------------------------------------------------------------*/
10 #include <string.h>
12 #include "proto.h"
13 #include "test.h"
14 #include "sjme/except.h"
15 #include "unit.h"
17 static sjme_errorCode nestedExcept(sjme_test* test,
18 volatile sjme_exceptTrace* trace)
20 SJME_EXCEPT_VDEF;
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.");
27 SJME_EXCEPT_FAIL:
28 /* Should be set. */
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();
36 /**
37 * Tests nested exception handling.
39 * @since 2023/12/08
41 SJME_TEST_DECLARE(testExceptFailNested)
43 SJME_EXCEPT_VDEF;
44 volatile sjme_exceptTrace* trace;
46 /* Setup test. */
47 trace = NULL;
49 /* Fail. */
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?");
58 SJME_EXCEPT_FAIL:
59 /* Should be set. */
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);