mirror of
https://github.com/sharkdp/bat.git
synced 2024-12-30 18:28:49 +01:00
Add test: builtin_mappings_matcher_only_compile_once
This commit is contained in:
parent
3865908439
commit
e30161ac3c
@ -148,6 +148,23 @@ mod tests {
|
|||||||
let _mappings = map.builtin_mappings().collect::<Vec<_>>();
|
let _mappings = map.builtin_mappings().collect::<Vec<_>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn builtin_mappings_matcher_only_compile_once() {
|
||||||
|
let map = SyntaxMapping::new();
|
||||||
|
|
||||||
|
let two_iterations: Vec<_> = (0..2)
|
||||||
|
.map(|_| {
|
||||||
|
// addresses of every matcher
|
||||||
|
map.builtin_mappings()
|
||||||
|
.map(|(matcher, _)| matcher as *const _ as usize)
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
// if the matchers are only compiled once, their address should remain the same
|
||||||
|
assert_eq!(two_iterations[0], two_iterations[1]);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn custom_mappings_work() {
|
fn custom_mappings_work() {
|
||||||
let mut map = SyntaxMapping::new();
|
let mut map = SyntaxMapping::new();
|
||||||
|
Loading…
Reference in New Issue
Block a user