Changeset eb0d9b7 for tests/array-collections/array-md-sbscr-cases.cfa
- Timestamp:
- Dec 20, 2025, 4:52:54 AM (29 hours ago)
- Branches:
- master
- Parents:
- 0210a543
- File:
-
- 1 edited
-
tests/array-collections/array-md-sbscr-cases.cfa (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tests/array-collections/array-md-sbscr-cases.cfa
r0210a543 reb0d9b7 231 231 } 232 232 233 // common function body, working on parameter wxyz, but for wxyz being different types 234 #define CHECK_NUM_SUBSCR_TYPE_COMPAT \ 235 valExpected = getMagicNumber(2, 3, 4, 5); \ 236 assert(( wxyz[2] [3] [4] [5] == valExpected )); \ 237 assert(( wxyz[2, 3] [4] [5] == valExpected )); \ 238 assert(( wxyz[2] [3, 4] [5] == valExpected )); \ 239 assert(( wxyz[2] [3] [4, 5] == valExpected )); \ 240 assert(( wxyz[2, 3, 4] [5] == valExpected )); \ 241 assert(( wxyz[2] [3, 4, 5] == valExpected )); \ 242 assert(( wxyz[2, 3, 4, 5] == valExpected )); \ 243 for ( i; Nw ) { \ 244 assert(( wxyz[ i, 3, 4, 5 ] == getMagicNumber(i, 3, 4, 5) )); \ 245 } \ 246 for ( i; Nx ) { \ 247 assert(( wxyz[ 2, i, 4, 5 ] == getMagicNumber(2, i, 4, 5) )); \ 248 } \ 249 for ( i; Ny ) { \ 250 assert(( wxyz[ 2, 3, i, 5 ] == getMagicNumber(2, 3, i, 5) )); \ 251 } \ 252 for ( i; Nz ) { \ 253 assert(( wxyz[ 2, 3, 4, i ] == getMagicNumber(2, 3, 4, i) )); \ 254 } 255 #define CHECK_NUM_SUBSCR_TYPE_COMPAT_ADDENDUM_RESHAPE \ 256 for ( i; Nw ) { \ 257 assert(( wxyz[ i, all, 4, 5 ][3] == getMagicNumber(i, 3, 4, 5) )); \ 258 } \ 259 for ( i; Nw ) { \ 260 assert(( wxyz[ all, 3, 4, 5 ][i] == getMagicNumber(i, 3, 4, 5) )); \ 261 } 262 263 // Low abstraction: simple declaration, cannot send a slice, can make a slice, runs fast 264 forall( [Nw], [Nx], [Ny], [Nz] ) 265 void test_numSubscrTypeCompatibility_lo( array( float, Nw, Nx, Ny, Nz ) & wxyz ) { 266 CHECK_NUM_SUBSCR_TYPE_COMPAT 267 CHECK_NUM_SUBSCR_TYPE_COMPAT_ADDENDUM_RESHAPE 268 } 269 270 // Medium abstraction: complex declaration, can send or make a slice, runs fast 271 forall( [Nw], Sw* 272 , [Nx], Sx* 273 , [Ny], Sy* 274 , [Nz], Sz* ) 275 void test_numSubscrTypeCompatibility_mid( 276 arpk( Nw, Sw, 277 arpk( Nx, Sx, 278 arpk( Ny, Sy, 279 arpk( Nz, Sz, float, float) 280 , float) 281 , float) 282 , float) & wxyz 283 ) { 284 CHECK_NUM_SUBSCR_TYPE_COMPAT 285 CHECK_NUM_SUBSCR_TYPE_COMPAT_ADDENDUM_RESHAPE 286 } 287 288 // High abstraction: mid-complexity declaration, can send a slice or a non-arpk, cannot make a slice, may not run fast 289 forall( [Nw], Awxyz & 290 , [Nx], Axyz & 291 , [Ny], Ayz & 292 , [Nz], Az & 293 | ar( Awxyz, Axyz, Nw ) 294 | ar( Axyz, Ayz, Nx ) 295 | ar( Ayz, Az, Ny ) 296 | ar( Az, float, Nz ) ) 297 void test_numSubscrTypeCompatibility_hi( Awxyz & wxyz ) { 298 CHECK_NUM_SUBSCR_TYPE_COMPAT 299 } 300 233 301 forall( [Nw], [Nx], [Ny], [Nz] ) 234 302 void test_numSubscrTypeCompatibility( tag(Nw), tag(Nx), tag(Ny), tag(Nz) ) { … … 237 305 fillHelloData(wxyz); 238 306 239 valExpected = getMagicNumber(2, 3, 4, 5); 240 assert(( wxyz [2] [3] [4] [5] == valExpected )); 241 assert(( wxyz[2, 3][4] [5] == valExpected )); 242 assert(( wxyz [2][3, 4][5] == valExpected )); 243 assert(( wxyz [2] [3][4, 5] == valExpected )); 244 assert(( wxyz[2, 3, 4][5] == valExpected )); 245 assert(( wxyz [2][3, 4, 5] == valExpected )); 246 assert(( wxyz[2, 3, 4, 5] == valExpected )); 247 248 for ( i; Nw ) { 249 assert(( wxyz[ i, 3, 4, 5 ] == getMagicNumber(i, 3, 4, 5) )); 250 } 251 252 for ( i; Nx ) { 253 assert(( wxyz[ 2, i, 4, 5 ] == getMagicNumber(2, i, 4, 5) )); 254 } 255 256 for ( i; Ny ) { 257 assert(( wxyz[ 2, 3, i, 5 ] == getMagicNumber(2, 3, i, 5) )); 258 } 259 260 for ( i; Nz ) { 261 assert(( wxyz[ 2, 3, 4, i ] == getMagicNumber(2, 3, 4, i) )); 262 } 263 264 for ( i; Nw ) { 265 assert(( wxyz[ i, all, 4, 5 ][3] == getMagicNumber(i, 3, 4, 5) )); 266 } 267 268 for ( i; Nw ) { 269 assert(( wxyz[ all, 3, 4, 5 ][i] == getMagicNumber(i, 3, 4, 5) )); 270 } 307 test_numSubscrTypeCompatibility_lo ( wxyz ); 308 test_numSubscrTypeCompatibility_mid( wxyz ); 309 test_numSubscrTypeCompatibility_hi ( wxyz ); 271 310 } 272 311
Note:
See TracChangeset
for help on using the changeset viewer.