1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-09-02 11:22:30 +01:00

Benchmark prototype

This commit is contained in:
cyqsimon
2023-12-11 10:38:59 +08:00
parent d792dc5804
commit f0a6fe216d
6 changed files with 57 additions and 50 deletions

View File

@@ -128,10 +128,8 @@ impl<'a> SyntaxMapping<'a> {
#[cfg(test)]
mod tests {
use once_cell::sync::Lazy;
use rusty_fork::rusty_fork_test;
use super::*;
#[test]
fn builtin_mappings_work() {
let map = SyntaxMapping::new();
@@ -151,33 +149,6 @@ mod tests {
let _mappings = map.builtin_mappings().collect::<Vec<_>>();
}
// disabled for ARM builds because of an issue with `rusty_fork`
#[cfg(not(any(target_arch = "arm", target_arch = "aarch64")))]
// lazy initialisation test needs to be run on a separate instance because
// it will race with other tests
// see: https://github.com/rust-lang/rust/issues/47506
rusty_fork_test! {
#[test]
fn builtin_mappings_are_lazily_evaluated() {
let map = SyntaxMapping::new();
assert!(BUILTIN_MAPPINGS
.iter()
.all(|(matcher, _)| Lazy::get(matcher).is_none()));
// calling `builtin_mappings` should not trigger evaluation
let mappings_iter = map.builtin_mappings();
assert!(BUILTIN_MAPPINGS
.iter()
.all(|(matcher, _)| Lazy::get(matcher).is_none()));
let _mappings: Vec<_> = mappings_iter.collect();
assert!(BUILTIN_MAPPINGS
.iter()
.all(|(matcher, _)| Lazy::get(matcher).is_some()));
}
}
#[test]
fn builtin_mappings_matcher_only_compile_once() {
let map = SyntaxMapping::new();