on 5f6e310 help sign in
bat/tests/no_duplicate_extensions.rs
35 lines 1.2 kB history raw
1use std::collections::HashSet;
3use bat::HighlightingAssets;
5#[test]
6fn no_duplicate_extensions() {
7 const KNOWN_EXCEPTIONS: &[&'static 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 Haskell syntax in 'Packages', we also ship the 'Cabal'
12 // syntax which comes with a "Haskell (improved)" syntax.
13 "hs",
14 // In addition to the standard JavaScript syntax in 'Packages', we also ship the
15 // 'Javascript (Babel)' syntax.
16 "js",
17 // The "Ruby Haml" syntax also comes with a '.sass' extension. However, we make sure
18 // that 'sass' is mapped to the 'Sass' syntax.
19 "sass",
20 ];
22 let assets = HighlightingAssets::from_binary();
24 let mut extensions = HashSet::new();
26 for syntax in assets.syntaxes() {
27 for extension in &syntax.file_extensions {
28 assert!(
29 KNOWN_EXCEPTIONS.contains(&extension.as_str()) || extensions.insert(extension),
30 "File extension / pattern \"{}\" appears twice in the syntax set",
31 extension
32 );
33 }
34 }