Skip to content

Commit fb0cddf

Browse files
committed
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.
1 parent c9fbb81 commit fb0cddf

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

Examples/test-suite/common.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,7 @@ C_TEST_CASES += \
695695
command_line_define \
696696
const_const \
697697
constant_expr_c \
698+
contract_c \
698699
default_args_c \
699700
empty_c \
700701
enums \

Examples/test-suite/contract.i

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ int test_prepost(int x, int y) {
4848
}
4949
%}
5050

51+
#ifdef __cplusplus
5152
/* Class tests */
5253

5354
%contract Foo::test_preassert(int x, int y) {
@@ -235,4 +236,4 @@ class myClass
235236
};
236237

237238
}
238-
239+
#endif

Examples/test-suite/contract_c.i

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
%module contract_c;
2+
3+
%include <exception.i>
4+
5+
%include "contract.i"

Lib/swig.swg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@
172172
#define %novaluewrapper %feature("novaluewrapper")
173173
#define %clearnovaluewrapper %feature("novaluewrapper","")
174174

175-
/* Contract support - Experimental and undocumented */
175+
/* Contract support - Experimental */
176176
#define %contract %feature("contract")
177177
#define %nocontract %feature("contract","0")
178178
#define %clearcontract %feature("contract","")

0 commit comments

Comments
 (0)