test(build): close residual helper mutants
Prove compact Rust type and vector facts plus default template paths, alias collision suppression, data parameter prefixes, keyed descendants, and absent Cargo roots. Classify only hemplate's infallible surface parser seam. req: diagnostics/006 req: diagnostics/004 req: codegen/005 req: test/021
This commit is contained in:
@@ -1973,6 +1973,7 @@ fn compact_tokens(tokens: &impl ToTokens) -> String {
|
||||
.replace(" < ", "<")
|
||||
.replace(" >", ">")
|
||||
.replace(" ,", ",")
|
||||
.replace(", ", ",")
|
||||
.replace(" & ", "&")
|
||||
.replace("& ", "&")
|
||||
}
|
||||
@@ -2399,6 +2400,47 @@ mod tests {
|
||||
// test req: diagnostics/004 req: diagnostics/006 req: surface/008
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rust_type_facts_are_compact_and_vector_specific() {
|
||||
let qualified: syn::Type =
|
||||
syn::parse_str("std::collections::HashMap<String, &crate::Thing<Left, Right>>")
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
compact_tokens(&qualified),
|
||||
"std::collections::HashMap<String,&crate::Thing<Left,Right>>"
|
||||
);
|
||||
let mutable: syn::Type = syn::parse_str("&mut crate::Thing").unwrap();
|
||||
assert_eq!(compact_tokens(&mutable), "&mut crate::Thing");
|
||||
let tuple: syn::Type = syn::parse_str("(&crate::Thing, String)").unwrap();
|
||||
assert_eq!(compact_tokens(&tuple), "(&crate::Thing,String)");
|
||||
let function: syn::Type = syn::parse_str("fn(&crate::Thing) -> &crate::Thing").unwrap();
|
||||
assert_eq!(
|
||||
compact_tokens(&function),
|
||||
"fn (&crate::Thing) ->&crate::Thing"
|
||||
);
|
||||
|
||||
assert_eq!(vec_element_type("Vec<String>"), Some("String".into()));
|
||||
assert_eq!(
|
||||
vec_element_type("std::vec::Vec<&crate::Thing<Left,Right>>"),
|
||||
Some("&crate::Thing<Left,Right>".into())
|
||||
);
|
||||
assert_eq!(vec_element_type("Vec< String >"), Some("String".into()));
|
||||
for invalid in [
|
||||
"",
|
||||
"String",
|
||||
"Vec<String",
|
||||
"VecString>",
|
||||
"alloc::vec::Vec<String>",
|
||||
] {
|
||||
assert_eq!(
|
||||
vec_element_type(invalid),
|
||||
None,
|
||||
"accepted non-vector type {invalid:?}"
|
||||
);
|
||||
}
|
||||
// test req: diagnostics/006
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rust_fact_collection_propagates_parse_and_recursive_directory_errors() {
|
||||
let base = test_dir("hemx-build-rust-fact-errors");
|
||||
@@ -2464,6 +2506,18 @@ mod tests {
|
||||
component_ident(root, Path::new("outside.heml")).unwrap(),
|
||||
"outside"
|
||||
);
|
||||
assert_eq!(data_param_ident("data-item-id"), Some("item_id".into()));
|
||||
assert_eq!(data_param_ident("aria-label"), None);
|
||||
assert_eq!(app().template_dir, PathBuf::from("templates"));
|
||||
assert_eq!(nearest_dir_with(Path::new("/"), "hemx-absent-marker"), None);
|
||||
|
||||
let mut exports = String::new();
|
||||
let mut used = BTreeSet::from(["shared".to_owned(), "shared_target".to_owned()]);
|
||||
push_root_export(&mut exports, "", "targets", &mut used, "shared", "target");
|
||||
assert!(
|
||||
exports.is_empty(),
|
||||
"colliding alias must not be emitted twice"
|
||||
);
|
||||
|
||||
let mut resources = BTreeMap::new();
|
||||
let first = insert_resource(
|
||||
@@ -3988,6 +4042,8 @@ fn main() {{
|
||||
assert!(is_inside_keyed_for(&surface, nested_scope));
|
||||
assert!(!is_inside_keyed_for(&surface, sibling_scope));
|
||||
assert!(!is_inside_keyed_for(&surface, ScopeId(u32::MAX)));
|
||||
assert!(has_descendant_keyed_for_scope(&surface, ScopeId(0)));
|
||||
assert!(!has_descendant_keyed_for_scope(&surface, sibling_scope));
|
||||
assert!(unkeyed_generated_target_diagnostic_for_scope(
|
||||
&surface,
|
||||
ScopeId(u32::MAX),
|
||||
|
||||
Reference in New Issue
Block a user