summaryrefslogtreecommitdiffstats
path: root/vendor/rayon/tests
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/rayon/tests')
-rw-r--r--vendor/rayon/tests/clones.rs6
-rw-r--r--vendor/rayon/tests/debug.rs2
-rw-r--r--vendor/rayon/tests/drain_vec.rs41
-rw-r--r--vendor/rayon/tests/iter_panic.rs2
4 files changed, 50 insertions, 1 deletions
diff --git a/vendor/rayon/tests/clones.rs b/vendor/rayon/tests/clones.rs
index 2f512ca05..2b78f0987 100644
--- a/vendor/rayon/tests/clones.rs
+++ b/vendor/rayon/tests/clones.rs
@@ -130,6 +130,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(|_| ()));
diff --git a/vendor/rayon/tests/debug.rs b/vendor/rayon/tests/debug.rs
index d107b1377..1cbf4e6ed 100644
--- a/vendor/rayon/tests/debug.rs
+++ b/vendor/rayon/tests/debug.rs
@@ -155,6 +155,8 @@ fn debug_adaptors() {
check(v.par_iter().map(Some).flatten_iter());
check(v.par_iter().fold(|| 0, |x, _| x));
check(v.par_iter().fold_with(0, |x, _| x));
+ check(v.par_iter().fold_chunks(3, || 0, |x, _| x));
+ check(v.par_iter().fold_chunks_with(3, 0, |x, _| x));
check(v.par_iter().try_fold(|| 0, |x, _| Some(x)));
check(v.par_iter().try_fold_with(0, |x, _| Some(x)));
check(v.par_iter().inspect(|_| ()));
diff --git a/vendor/rayon/tests/drain_vec.rs b/vendor/rayon/tests/drain_vec.rs
new file mode 100644
index 000000000..08f1120b7
--- /dev/null
+++ b/vendor/rayon/tests/drain_vec.rs
@@ -0,0 +1,41 @@
+use rayon::prelude::*;
+
+#[test]
+fn drain_vec_yielded() {
+ let mut vec_org = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
+
+ let yielded = vec_org.par_drain(0..5).collect::<Vec<_>>();
+
+ assert_eq!(&yielded, &[0, 1, 2, 3, 4]);
+ assert_eq!(&vec_org, &[5, 6, 7, 8, 9]);
+}
+
+#[test]
+fn drain_vec_dropped() {
+ let mut vec_org = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
+
+ let yielded = vec_org.par_drain(0..5);
+
+ drop(yielded);
+ assert_eq!(&vec_org, &[5, 6, 7, 8, 9]);
+}
+
+#[test]
+fn drain_vec_empty_range_yielded() {
+ let mut vec_org = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
+
+ let yielded = vec_org.par_drain(5..5).collect::<Vec<_>>();
+
+ assert_eq!(&yielded, &[]);
+ assert_eq!(&vec_org, &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
+}
+
+#[test]
+fn drain_vec_empty_range_dropped() {
+ let mut vec_org = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
+
+ let yielded = vec_org.par_drain(5..5);
+
+ drop(yielded);
+ assert_eq!(&vec_org, &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
+}
diff --git a/vendor/rayon/tests/iter_panic.rs b/vendor/rayon/tests/iter_panic.rs
index 4885a28be..37d4d6a3a 100644
--- a/vendor/rayon/tests/iter_panic.rs
+++ b/vendor/rayon/tests/iter_panic.rs
@@ -47,6 +47,6 @@ fn iter_panic_fuse() {
assert!(count(iter.clone().panic_fuse().inspect(check)) < expected);
// Try in reverse to be sure we hit the producer case.
- assert!(count(iter.clone().panic_fuse().inspect(check).rev()) < expected);
+ assert!(count(iter.panic_fuse().inspect(check).rev()) < expected);
});
}