-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathno_duplicate_extensions.rs
37 lines (32 loc) · 1.22 KB
/
no_duplicate_extensions.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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 \"{extension}\" appears twice in the syntax set"
);
}
}
}