mirror of
https://github.com/sharkdp/bat
synced 2024-11-27 06:10:20 +00:00
a81009607a
Or rather, introduce new versions of these methods and deprecate the old ones. This is preparation to enable robust and user-friendly support for lazy-loading. With lazy-loading, we don't know if the SyntaxSet is valid until after we try to use it, so wherever we try to use it, we need to return a Result. See discussion about panics in #1747.
38 lines
1.2 KiB
Rust
38 lines
1.2 KiB
Rust
use std::collections::HashSet;
|
|
|
|
use bat::assets::HighlightingAssets;
|
|
|
|
#[test]
|
|
fn no_duplicate_extensions() {
|
|
const KNOWN_EXCEPTIONS: &[&str] = &[
|
|
// 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",
|
|
// The '.fs' extension appears in F# and GLSL.
|
|
// We default to F#.
|
|
"fs",
|
|
// SystemVerilog and Verilog both use .v files.
|
|
// We default to Verilog.
|
|
"v",
|
|
];
|
|
|
|
let assets = HighlightingAssets::from_binary();
|
|
|
|
let mut extensions = HashSet::new();
|
|
|
|
for syntax in assets.get_syntaxes().expect("this is a #[test]") {
|
|
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
|
|
);
|
|
}
|
|
}
|
|
}
|