use super::tests::{accepted, refused};
#[test]
fn every_shape_of_the_retired_word_is_pointed_at_the_recipe() {
for written in [
quote::quote!(dedup(hash)),
quote::quote!(dedup(eq)),
quote::quote!(dedup),
quote::quote!(dedup()),
quote::quote!(dedup(nonsense)),
] {
let refusal = refused(quote::quote! {
#[ingraph(#written)]
pub struct Media {
#[ingraph(fuse)]
shots: Shots,
}
});
assert!(
refusal.contains("`dedup(…)` is a RECIPE's word"),
"`{written}`: {refusal}",
);
assert!(
refusal.contains("#[ingraph::search(dedup(hash))]"),
"the sentence stopped naming where the word went — `{written}`: {refusal}",
);
assert!(
!refusal.contains("unknown entry"),
"the retired word fell through to the roster — `{written}`: {refusal}",
);
}
}
#[test]
fn the_roster_and_the_near_miss_both_stop_offering_it() {
let refusal = refused(quote::quote! {
#[ingraph(dedupe(hash))]
pub struct Media {
#[ingraph(fuse)]
shots: Shots,
}
});
assert!(refusal.contains("unknown entry"), "{refusal}");
for word in [
"`crate = \"…\"`",
"`engines(<word> = \"path::To::Engine\")`",
"`retired(<engine>)`",
"`generations(<engine>)`",
] {
assert!(
refusal.contains(word),
"the roster stopped naming a word that DOES decide something ({word}): {refusal}",
);
}
assert!(
!refusal.contains("`dedup(…)`"),
"the roster still lists a retired word: {refusal}",
);
assert!(
!refusal.contains("did you mean `dedup`"),
"the near miss points at the retired word: {refusal}",
);
}
#[test]
fn the_two_surviving_words_are_read_as_they_were() {
let model = accepted(quote::quote! {
#[ingraph(crate = "::app::ingraph", engines(hnsw = "app::hnsw::Hnsw"))]
pub struct Media {
#[ingraph(fuse)]
shots: Shots,
}
});
let krate = &model.krate;
assert_eq!(
quote::quote!(#krate).to_string().replace(' ', ""),
"::app::ingraph"
);
assert_eq!(model.engines.len(), 1);
assert_eq!(model.fused.len(), 1);
}