2020-03-15 14:14:01 +01:00
|
|
|
use std::collections::HashSet;
|
|
|
|
|
2020-04-22 18:10:26 +02:00
|
|
|
use bat::assets::HighlightingAssets;
|
2020-03-15 14:14:01 +01:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn no_duplicate_extensions() {
|
2020-04-24 08:46:01 +02:00
|
|
|
const KNOWN_EXCEPTIONS: &[&str] = &[
|
2020-03-15 14:14:01 +01:00
|
|
|
// The '.h' extension currently appears in multiple syntaxes: C, C++, Objective C,
|
|
|
|
// Objective C++
|
|
|
|
"h",
|
|
|
|
// In addition to the standard JavaScript syntax in 'Packages', we also ship the
|
|
|
|
// 'Javascript (Babel)' syntax.
|
|
|
|
"js",
|
|
|
|
// The "Ruby Haml" syntax also comes with a '.sass' extension. However, we make sure
|
|
|
|
// that 'sass' is mapped to the 'Sass' syntax.
|
|
|
|
"sass",
|
2020-09-20 20:47:21 +02:00
|
|
|
// The '.fs' extension appears in F# and GLSL.
|
|
|
|
// We default to F#.
|
2020-06-27 02:42:05 +02:00
|
|
|
"fs",
|
2021-03-11 06:35:14 +01:00
|
|
|
// SystemVerilog and Verilog both use .v files.
|
|
|
|
// We default to Verilog.
|
|
|
|
"v",
|
2020-03-15 14:14:01 +01:00
|
|
|
];
|
|
|
|
|
2020-03-21 16:48:27 +01:00
|
|
|
let assets = HighlightingAssets::from_binary();
|
2020-03-15 14:14:01 +01:00
|
|
|
|
|
|
|
let mut extensions = HashSet::new();
|
|
|
|
|
2021-07-27 09:43:51 +02:00
|
|
|
for syntax in assets.get_syntaxes().expect("this is a #[test]") {
|
2020-03-15 14:14:01 +01:00
|
|
|
for extension in &syntax.file_extensions {
|
|
|
|
assert!(
|
|
|
|
KNOWN_EXCEPTIONS.contains(&extension.as_str()) || extensions.insert(extension),
|
|
|
|
"File extension / pattern \"{}\" appears twice in the syntax set",
|
|
|
|
extension
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|