1 use std::collections::HashSet;
2
3 use bat::assets::HighlightingAssets;
4
5 #[test]
no_duplicate_extensions()6 fn no_duplicate_extensions() {
7 const KNOWN_EXCEPTIONS: &[&str] = &[
8 // The '.h' extension currently appears in multiple syntaxes: C, C++, Objective C,
9 // Objective C++
10 "h",
11 // In addition to the standard JavaScript syntax in 'Packages', we also ship the
12 // 'Javascript (Babel)' syntax.
13 "js",
14 // The "Ruby Haml" syntax also comes with a '.sass' extension. However, we make sure
15 // that 'sass' is mapped to the 'Sass' syntax.
16 "sass",
17 // The '.fs' extension appears in F# and GLSL.
18 // We default to F#.
19 "fs",
20 // SystemVerilog and Verilog both use .v files.
21 // We default to Verilog.
22 "v",
23 ];
24
25 let assets = HighlightingAssets::from_binary();
26
27 let mut extensions = HashSet::new();
28
29 for syntax in assets.syntaxes() {
30 for extension in &syntax.file_extensions {
31 assert!(
32 KNOWN_EXCEPTIONS.contains(&extension.as_str()) || extensions.insert(extension),
33 "File extension / pattern \"{}\" appears twice in the syntax set",
34 extension
35 );
36 }
37 }
38 }
39