mirror of
				https://github.com/sharkdp/bat.git
				synced 2025-10-29 22:24:35 +00:00 
			
		
		
		
	Add test: builtin_mappings_matcher_only_compile_once
				
					
				
			This commit is contained in:
		| @@ -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(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user