diff --git a/src/syntax_mapping.rs b/src/syntax_mapping.rs index a7923a5c..e523f85e 100644 --- a/src/syntax_mapping.rs +++ b/src/syntax_mapping.rs @@ -148,6 +148,23 @@ mod tests { let _mappings = map.builtin_mappings().collect::>(); } + #[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::>() + }) + .collect(); + + // if the matchers are only compiled once, their address should remain the same + assert_eq!(two_iterations[0], two_iterations[1]); + } + #[test] fn custom_mappings_work() { let mut map = SyntaxMapping::new();