Skip to content

Commit 7758ffb

Browse files
committed
Add tests for Zip with 9 producers
1 parent b302ab3 commit 7758ffb

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

tests/azip.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,3 +483,22 @@ fn test_zip_all_empty_array()
483483
assert!(Zip::from(&a).and(&b).all(|&_x, &_y| true));
484484
assert!(Zip::from(&a).and(&b).all(|&_x, &_y| false));
485485
}
486+
487+
#[test]
488+
fn test_azip9()
489+
{
490+
let mut a = Array::<i32, _>::zeros(62);
491+
let b = Array::from_shape_fn(a.dim(), |j| j as i32);
492+
let c = Array::from_shape_fn(a.dim(), |j| (j * 2) as i32);
493+
let d = Array::from_shape_fn(a.dim(), |j| (j * 4) as i32);
494+
let e = Array::from_shape_fn(a.dim(), |j| (j * 8) as i32);
495+
let f = Array::from_shape_fn(a.dim(), |j| (j * 16) as i32);
496+
let g = Array::from_shape_fn(a.dim(), |j| (j * 32) as i32);
497+
let h = Array::from_shape_fn(a.dim(), |j| (j * 64) as i32);
498+
let i = Array::from_shape_fn(a.dim(), |j| (j * 128) as i32);
499+
azip!((a in &mut a, &b in &b, &c in &c, &d in &d, &e in &e, &f in &f, &g in &g, &h in &h, &i in &i){
500+
*a = b + c + d + e + f + g + h + i;
501+
});
502+
let x = Array::from_shape_fn(a.dim(), |j| (j * 255) as i32);
503+
assert_equal(cloned(&a), x);
504+
}

tests/par_azip.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,22 @@ fn test_indices_1()
7171
});
7272
assert_eq!(count.load(Ordering::SeqCst), a1.len());
7373
}
74+
75+
#[test]
76+
fn test_par_azip9()
77+
{
78+
let mut a = Array::<i32, _>::zeros(62);
79+
let b = Array::from_shape_fn(a.dim(), |j| j as i32);
80+
let c = Array::from_shape_fn(a.dim(), |j| (j * 2) as i32);
81+
let d = Array::from_shape_fn(a.dim(), |j| (j * 4) as i32);
82+
let e = Array::from_shape_fn(a.dim(), |j| (j * 8) as i32);
83+
let f = Array::from_shape_fn(a.dim(), |j| (j * 16) as i32);
84+
let g = Array::from_shape_fn(a.dim(), |j| (j * 32) as i32);
85+
let h = Array::from_shape_fn(a.dim(), |j| (j * 64) as i32);
86+
let i = Array::from_shape_fn(a.dim(), |j| (j * 128) as i32);
87+
par_azip!((a in &mut a, &b in &b, &c in &c, &d in &d, &e in &e, &f in &f, &g in &g, &h in &h, &i in &i){
88+
*a = b + c + d + e + f + g + h + i;
89+
});
90+
let x = Array::from_shape_fn(a.dim(), |j| (j * 255) as i32);
91+
assert_equal(cloned(&a), x);
92+
}

0 commit comments

Comments
 (0)