summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/util')
-rw-r--r--src/util/language.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/util/language.rs b/src/util/language.rs
index f0870c8..080b26e 100644
--- a/src/util/language.rs
+++ b/src/util/language.rs
@@ -16,6 +16,9 @@ fn detect_from_extension(filename: &Path) -> Option<&'static str> {
Some("rs") => Some("rust"),
Some("py") => Some("python"),
Some("json") => Some("json"),
+ Some("toml") => Some("toml"),
+ Some("yaml") | Some("yml") => Some("yaml"),
+ Some("js") | Some("jsx") => Some("javascript"),
_ => None,
}
}
@@ -69,4 +72,29 @@ mod tests {
let contents = "#!/bin/bash\nprint('hello')";
assert_eq!(detect_language(Path::new("main.py"), contents), "python");
}
+
+ #[test]
+ fn yaml_extension_is_detected() {
+ assert_eq!(detect_language(Path::new("config.yaml"), ""), "yaml");
+ }
+
+ #[test]
+ fn yml_alias_maps_to_yaml() {
+ assert_eq!(detect_language(Path::new("config.yml"), ""), "yaml");
+ }
+
+ #[test]
+ fn js_extension_is_detected() {
+ assert_eq!(detect_language(Path::new("file.js"), ""), "javascript");
+ }
+
+ #[test]
+ fn jsx_maps_to_javascript() {
+ assert_eq!(detect_language(Path::new("file.jsx"), ""), "javascript");
+ }
+
+ #[test]
+ fn toml_extension_is_detected() {
+ assert_eq!(detect_language(Path::new("Cargo.toml"), ""), "toml");
+ }
}