use rayon::prelude::*; use std::{env, path::PathBuf, sync::Arc}; use swc_common::{FilePathMapping, SourceFile, SourceMap}; #[test] fn no_overlap() { let cm = Arc::new(SourceMap::new(FilePathMapping::empty())); let files: Vec> = (0..100000) .into_par_iter() .map(|_| { let fm = cm .load_file( &PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()) .join("tests") .join("concurrent.js"), ) .unwrap(); fm }) .collect::>(); // This actually tests if there is overlap let mut start = files.clone(); start.sort_by_key(|f| f.start_pos); let mut end = files.clone(); end.sort_by_key(|f| f.end_pos); start .into_par_iter() .zip(end) .for_each(|(start, end): (Arc, Arc)| { assert_eq!(start.start_pos, end.start_pos); assert_eq!(start.end_pos, end.end_pos); assert!(start.start_pos < start.end_pos); cm.lookup_char_pos(start.start_pos); }); }