Add C "contract" test

Tests that the `%contract` code (viz., each target language's
implementation of SWIG_contract_assert) compiles in C as expected. Update
the note in the source code since `%contract` is in the official
documentation.
This commit is contained in:
Seth R Johnson 2022-02-12 18:13:20 -05:00
parent c9fbb81e4a
commit fb0cddfd2b
4 changed files with 9 additions and 2 deletions

View File

@ -695,6 +695,7 @@ C_TEST_CASES += \
command_line_define \ command_line_define \
const_const \ const_const \
constant_expr_c \ constant_expr_c \
contract_c \
default_args_c \ default_args_c \
empty_c \ empty_c \
enums \ enums \

View File

@ -48,6 +48,7 @@ int test_prepost(int x, int y) {
} }
%} %}
#ifdef __cplusplus
/* Class tests */ /* Class tests */
%contract Foo::test_preassert(int x, int y) { %contract Foo::test_preassert(int x, int y) {
@ -235,4 +236,4 @@ class myClass
}; };
} }
#endif

View File

@ -0,0 +1,5 @@
%module contract_c;
%include <exception.i>
%include "contract.i"

View File

@ -172,7 +172,7 @@
#define %novaluewrapper %feature("novaluewrapper") #define %novaluewrapper %feature("novaluewrapper")
#define %clearnovaluewrapper %feature("novaluewrapper","") #define %clearnovaluewrapper %feature("novaluewrapper","")
/* Contract support - Experimental and undocumented */ /* Contract support - Experimental */
#define %contract %feature("contract") #define %contract %feature("contract")
#define %nocontract %feature("contract","0") #define %nocontract %feature("contract","0")
#define %clearcontract %feature("contract","") #define %clearcontract %feature("contract","")