2020-02-18 06:27:13 +03:00
|
|
|
use rayon::prelude::*;
|
|
|
|
use std::{env, path::PathBuf, sync::Arc};
|
|
|
|
use swc_common::{FilePathMapping, SourceFile, SourceMap};
|
|
|
|
|
|
|
|
fn init() {
|
2020-02-19 17:13:08 +03:00
|
|
|
let _ = rayon::ThreadPoolBuilder::new()
|
2020-02-18 06:27:13 +03:00
|
|
|
.num_threads(100)
|
2020-02-19 17:13:08 +03:00
|
|
|
.build_global();
|
2020-02-18 06:27:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn no_overlap() {
|
2020-02-19 17:13:08 +03:00
|
|
|
init();
|
|
|
|
|
2020-02-18 06:27:13 +03:00
|
|
|
let cm = Arc::new(SourceMap::new(FilePathMapping::empty()));
|
|
|
|
|
|
|
|
let files: Vec<Arc<SourceFile>> = (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::<Vec<_>>();
|
|
|
|
|
|
|
|
// This actually tests if there is overlap
|
|
|
|
|
|
|
|
let start = files.clone().sort_by_key(|f| f.start_pos);
|
|
|
|
let end = files.clone().sort_by_key(|f| f.end_pos);
|
|
|
|
|
|
|
|
assert_eq!(start, end);
|
|
|
|
}
|