first pass of merging in warp (doesn't build)
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
use std::path::Path;
|
||||
|
||||
use crate::{language_by_filename, load_language, SUPPORTED_LANGUAGES};
|
||||
use warp_util::standardized_path::StandardizedPath;
|
||||
|
||||
use crate::{language_by_filename, language_by_local_filename, load_language, SUPPORTED_LANGUAGES};
|
||||
|
||||
/// Validate that every supported language can be loaded successfully.
|
||||
/// This catches invalid node types, syntax errors, and other issues in .scm query files
|
||||
@@ -23,12 +25,56 @@ fn all_supported_languages_load_successfully() {
|
||||
);
|
||||
}
|
||||
|
||||
/// Both `.html` and the legacy three-character `.htm` extension should resolve to
|
||||
/// the same HTML language entry. `.htm` is widely produced by static-site generators
|
||||
/// and historical web tooling (DOS 8.3 filename limits) and is already treated as
|
||||
/// an HTML/text file elsewhere in the codebase
|
||||
/// (see `is_development_text_extension` in `crates/warp_util/src/file_type.rs`).
|
||||
#[test]
|
||||
fn cpp_header_extensions_resolve_to_cpp_language() {
|
||||
for filename in ["header.hpp", "header.hxx", "header.H"] {
|
||||
let language = language_by_filename(Path::new(filename))
|
||||
.unwrap_or_else(|| panic!("expected {filename} to resolve to C++"));
|
||||
|
||||
assert_eq!(language.display_name(), "C++");
|
||||
fn html_extensions_resolve_to_html() {
|
||||
for filename in ["index.html", "index.htm"] {
|
||||
let path = StandardizedPath::try_new(&format!("/tmp/{filename}"))
|
||||
.expect("test path should be absolute");
|
||||
let language = language_by_filename(&path)
|
||||
.unwrap_or_else(|| panic!("expected {filename} to resolve to a language"));
|
||||
assert_eq!(
|
||||
language.display_name(),
|
||||
"HTML",
|
||||
"{filename} should resolve to HTML",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn local_html_extensions_resolve_to_html() {
|
||||
for filename in ["index.html", "index.htm"] {
|
||||
let path = Path::new(filename);
|
||||
let language = language_by_local_filename(path)
|
||||
.unwrap_or_else(|| panic!("expected {filename} to resolve to a language"));
|
||||
assert_eq!(
|
||||
language.display_name(),
|
||||
"HTML",
|
||||
"{filename} should resolve to HTML",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// `.command` is the macOS convention for double-clickable shell scripts.
|
||||
/// Make sure `language_by_filename` recognizes it as shell so the editor
|
||||
/// renders syntax highlighting instead of the
|
||||
/// "Language support is unavailable for this file type" footer.
|
||||
#[test]
|
||||
fn command_extension_resolves_to_shell() {
|
||||
let path =
|
||||
StandardizedPath::try_new("/tmp/script.command").expect("test path should be absolute");
|
||||
let language =
|
||||
language_by_filename(&path).expect("`.command` files should resolve to a language");
|
||||
assert_eq!(language.display_name(), "Shell");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn local_command_extension_resolves_to_shell() {
|
||||
let language = language_by_local_filename(Path::new("script.command"))
|
||||
.expect("`.command` files should resolve to a language");
|
||||
assert_eq!(language.display_name(), "Shell");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user