diff options
Diffstat (limited to 'vendor/rustc-rayon/tests/clones.rs')
-rw-r--r-- | vendor/rustc-rayon/tests/clones.rs | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/vendor/rustc-rayon/tests/clones.rs b/vendor/rustc-rayon/tests/clones.rs index 2f512ca05..0d6c86487 100644 --- a/vendor/rustc-rayon/tests/clones.rs +++ b/vendor/rustc-rayon/tests/clones.rs @@ -10,6 +10,13 @@ where assert_eq!(a, b); } +fn check_count<I>(iter: I) +where + I: ParallelIterator + Clone, +{ + assert_eq!(iter.clone().count(), iter.count()); +} + #[test] fn clone_binary_heap() { use std::collections::BinaryHeap; @@ -130,6 +137,12 @@ fn clone_adaptors() { check(v.par_iter().flatten_iter()); check(v.par_iter().with_max_len(1).fold(|| 0, |x, _| x)); check(v.par_iter().with_max_len(1).fold_with(0, |x, _| x)); + check(v.par_iter().with_max_len(1).fold_chunks(1, || 0, |x, _| x)); + check( + v.par_iter() + .with_max_len(1) + .fold_chunks_with(1, 0, |x, _| x), + ); check(v.par_iter().with_max_len(1).try_fold(|| 0, |_, &x| x)); check(v.par_iter().with_max_len(1).try_fold_with(0, |_, &x| x)); check(v.par_iter().inspect(|_| ())); @@ -144,8 +157,10 @@ fn clone_adaptors() { check(v.par_iter().panic_fuse()); check(v.par_iter().positions(|_| true)); check(v.par_iter().rev()); - check(v.par_iter().skip(1)); - check(v.par_iter().take(1)); + check(v.par_iter().skip(42)); + check(v.par_iter().skip_any_while(|_| false)); + check(v.par_iter().take(42)); + check(v.par_iter().take_any_while(|_| true)); check(v.par_iter().cloned().while_some()); check(v.par_iter().with_max_len(1)); check(v.par_iter().with_min_len(1)); @@ -155,6 +170,13 @@ fn clone_adaptors() { } #[test] +fn clone_counted_adaptors() { + let v: Vec<_> = (0..1000).collect(); + check_count(v.par_iter().skip_any(42)); + check_count(v.par_iter().take_any(42)); +} + +#[test] fn clone_empty() { check(rayon::iter::empty::<i32>()); } |