@@ -154,18 +154,35 @@ TheModule.print('void * ' + voidPointerUser.GetVoidPointer());
154
154
// Array tests
155
155
156
156
var arrayClass = new TheModule . ArrayClass ( ) ;
157
- TheModule . print ( 'array [0] == ' + arrayClass . get_int_array ( 0 ) ) ;
158
- TheModule . print ( 'array [7] == ' + arrayClass . get_int_array ( 7 ) ) ;
157
+ TheModule . print ( 'int_array [0] == ' + arrayClass . get_int_array ( 0 ) ) ;
158
+ TheModule . print ( 'int_array [7] == ' + arrayClass . get_int_array ( 7 ) ) ;
159
159
arrayClass . set_int_array ( 0 , 42 ) ;
160
160
arrayClass . set_int_array ( 7 , 43 ) ;
161
- TheModule . print ( 'array[0] == ' + arrayClass . get_int_array ( 0 ) ) ;
162
- TheModule . print ( 'array[7] == ' + arrayClass . get_int_array ( 7 ) ) ;
161
+ TheModule . print ( 'int_array[0] == ' + arrayClass . get_int_array ( 0 ) ) ;
162
+ TheModule . print ( 'int_array[7] == ' + arrayClass . get_int_array ( 7 ) ) ;
163
+
164
+ try {
165
+ arrayClass . set_int_array ( - 1 , struct ) ;
166
+ } catch ( e ) {
167
+ TheModule . print ( 'idx -1: ' + e ) ;
168
+ }
169
+
170
+ try {
171
+ arrayClass . set_int_array ( 8 , struct ) ;
172
+ } catch ( e ) {
173
+ TheModule . print ( 'idx 8: ' + e ) ;
174
+ }
163
175
164
176
TheModule . print ( 'struct_array[0].attr1 == ' + arrayClass . get_struct_array ( 0 ) . get_attr1 ( ) ) ;
165
177
TheModule . print ( 'struct_array[0].attr2 == ' + arrayClass . get_struct_array ( 0 ) . get_attr2 ( ) ) ;
166
178
TheModule . print ( 'struct_array[7].attr1 == ' + arrayClass . get_struct_array ( 7 ) . get_attr1 ( ) ) ;
167
179
TheModule . print ( 'struct_array[7].attr2 == ' + arrayClass . get_struct_array ( 7 ) . get_attr2 ( ) ) ;
168
180
181
+ // Verify that bounds checking is *not* enabled when not asked for.
182
+ // This actually causes an illegal memory access, but as it's only a read, and the return
183
+ // value is not used, it shouldn't cause any problems in practice.
184
+ arrayClass . get_struct_array ( 8 ) ;
185
+
169
186
var struct = new TheModule . StructInArray ( 13 , 17 ) ;
170
187
arrayClass . set_struct_array ( 0 , struct ) ;
171
188
struct = new TheModule . StructInArray ( 14 , 18 ) ;
0 commit comments