diff --git a/SWIG/Examples/test-suite/array_member.i b/SWIG/Examples/test-suite/array_member.i new file mode 100644 index 000000000..a80e92aa4 --- /dev/null +++ b/SWIG/Examples/test-suite/array_member.i @@ -0,0 +1,24 @@ +%module array_member + +%inline %{ + +typedef struct Foo { + char text[8]; + int data[8]; +} Foo; + +int global_data[8] = { 0,1,2,3,4,5,6,7 }; + +void set_value(int *x, int i, int v) { + x[i] = v; +} + +int get_value(int *x, int i) { + return x[i]; +} +%} + + + + + diff --git a/SWIG/Examples/test-suite/common.mk b/SWIG/Examples/test-suite/common.mk index 228ea2529..ffd48584a 100644 --- a/SWIG/Examples/test-suite/common.mk +++ b/SWIG/Examples/test-suite/common.mk @@ -43,7 +43,6 @@ DYNAMIC_LIB_PATH = $(RUNTIMEDIR):. # Broken C++ test cases. (Can be run individually using make testcase.cpptest.) CPP_TEST_BROKEN += \ - typedef_class \ array_typedef_memberin \ exception_order \ template_default_arg \ @@ -70,6 +69,7 @@ CPP_TEST_CASES += \ arrayref \ arrays_global \ arrays_global_twodim \ + array_member \ arrays_scope \ bloody_hell \ bool_default \ @@ -222,6 +222,7 @@ CPP_TEST_CASES += \ template_whitespace \ throw_exception \ typedef_array_member \ + typedef_class \ typedef_funcptr \ typedef_inherit \ typedef_mptr \ diff --git a/SWIG/Examples/test-suite/python/array_member_runme.py b/SWIG/Examples/test-suite/python/array_member_runme.py new file mode 100644 index 000000000..95cf03b44 --- /dev/null +++ b/SWIG/Examples/test-suite/python/array_member_runme.py @@ -0,0 +1,21 @@ +from array_member import * + +f = Foo() +f.data = cvar.global_data + +for i in range(0,8): + if get_value(f.data,i) != get_value(cvar.global_data,i): + raise RuntimeError, "Bad array assignment" + + +for i in range(0,8): + set_value(f.data,i,-i) + +cvar.global_data = f.data + +for i in range(0,8): + if get_value(f.data,i) != get_value(cvar.global_data,i): + raise RuntimeError, "Bad array assignment" + + + diff --git a/SWIG/Examples/test-suite/typedef_class.i b/SWIG/Examples/test-suite/typedef_class.i index a1c1f600b..5a75305c9 100644 --- a/SWIG/Examples/test-suite/typedef_class.i +++ b/SWIG/Examples/test-suite/typedef_class.i @@ -13,5 +13,4 @@ class B typedef RealA A2; int testA (const A2& a) {return a.a;} }; - %}