aboutsummaryrefslogtreecommitdiff
path: root/vendor/rayon/tests/collect.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2024-07-19 15:37:58 +0300
committerValentin Popov <valentin@popov.link>2024-07-19 15:37:58 +0300
commita990de90fe41456a23e58bd087d2f107d321f3a1 (patch)
tree15afc392522a9e85dc3332235e311b7d39352ea9 /vendor/rayon/tests/collect.rs
parent3d48cd3f81164bbfc1a755dc1d4a9a02f98c8ddd (diff)
downloadfparkan-a990de90fe41456a23e58bd087d2f107d321f3a1.tar.xz
fparkan-a990de90fe41456a23e58bd087d2f107d321f3a1.zip
Deleted vendor folder
Diffstat (limited to 'vendor/rayon/tests/collect.rs')
-rw-r--r--vendor/rayon/tests/collect.rs113
1 files changed, 0 insertions, 113 deletions
diff --git a/vendor/rayon/tests/collect.rs b/vendor/rayon/tests/collect.rs
deleted file mode 100644
index bfb080c..0000000
--- a/vendor/rayon/tests/collect.rs
+++ /dev/null
@@ -1,113 +0,0 @@
-use rayon::prelude::*;
-
-use std::panic;
-use std::sync::atomic::AtomicUsize;
-use std::sync::atomic::Ordering;
-use std::sync::Mutex;
-
-#[test]
-#[cfg_attr(not(panic = "unwind"), ignore)]
-fn collect_drop_on_unwind() {
- struct Recorddrop<'a>(i64, &'a Mutex<Vec<i64>>);
-
- impl<'a> Drop for Recorddrop<'a> {
- fn drop(&mut self) {
- self.1.lock().unwrap().push(self.0);
- }
- }
-
- let test_collect_panic = |will_panic: bool| {
- let test_vec_len = 1024;
- let panic_point = 740;
-
- let mut inserts = Mutex::new(Vec::new());
- let mut drops = Mutex::new(Vec::new());
-
- let mut a = (0..test_vec_len).collect::<Vec<_>>();
- let b = (0..test_vec_len).collect::<Vec<_>>();
-
- let _result = panic::catch_unwind(panic::AssertUnwindSafe(|| {
- let mut result = Vec::new();
- a.par_iter_mut()
- .zip(&b)
- .map(|(&mut a, &b)| {
- if a > panic_point && will_panic {
- panic!("unwinding for test");
- }
- let elt = a + b;
- inserts.lock().unwrap().push(elt);
- Recorddrop(elt, &drops)
- })
- .collect_into_vec(&mut result);
-
- // If we reach this point, this must pass
- assert_eq!(a.len(), result.len());
- }));
-
- let inserts = inserts.get_mut().unwrap();
- let drops = drops.get_mut().unwrap();
- println!("{:?}", inserts);
- println!("{:?}", drops);
-
- assert_eq!(inserts.len(), drops.len(), "Incorrect number of drops");
- // sort to normalize order
- inserts.sort();
- drops.sort();
- assert_eq!(inserts, drops, "Incorrect elements were dropped");
- };
-
- for &should_panic in &[true, false] {
- test_collect_panic(should_panic);
- }
-}
-
-#[test]
-#[cfg_attr(not(panic = "unwind"), ignore)]
-fn collect_drop_on_unwind_zst() {
- static INSERTS: AtomicUsize = AtomicUsize::new(0);
- static DROPS: AtomicUsize = AtomicUsize::new(0);
-
- struct RecorddropZst;
-
- impl Drop for RecorddropZst {
- fn drop(&mut self) {
- DROPS.fetch_add(1, Ordering::SeqCst);
- }
- }
-
- let test_collect_panic = |will_panic: bool| {
- INSERTS.store(0, Ordering::SeqCst);
- DROPS.store(0, Ordering::SeqCst);
-
- let test_vec_len = 1024;
- let panic_point = 740;
-
- let a = (0..test_vec_len).collect::<Vec<_>>();
-
- let _result = panic::catch_unwind(panic::AssertUnwindSafe(|| {
- let mut result = Vec::new();
- a.par_iter()
- .map(|&a| {
- if a > panic_point && will_panic {
- panic!("unwinding for test");
- }
- INSERTS.fetch_add(1, Ordering::SeqCst);
- RecorddropZst
- })
- .collect_into_vec(&mut result);
-
- // If we reach this point, this must pass
- assert_eq!(a.len(), result.len());
- }));
-
- let inserts = INSERTS.load(Ordering::SeqCst);
- let drops = DROPS.load(Ordering::SeqCst);
-
- assert_eq!(inserts, drops, "Incorrect number of drops");
- assert!(will_panic || drops == test_vec_len)
- };
-
- for &should_panic in &[true, false] {
- test_collect_panic(should_panic);
- }
-}