Add test: builtin_mappings_matcher_only_compile_once

This commit is contained in:
cyqsimon 2023-11-06 11:18:20 +08:00
parent 3865908439
commit e30161ac3c
No known key found for this signature in database
GPG Key ID: 1D8CE2F297390D65

View File

@ -148,6 +148,23 @@ mod tests {
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]
fn custom_mappings_work() {
let mut map = SyntaxMapping::new();