ingraph-derive 0.1.0

The attribute and derive macros for ingraph: the words a record, node, key, filter and vocabulary declaration is written in.
Documentation
//! `dedup(…)` AT A GRAPH ROOT, RETIRED — the word that used to choose the join the root's fused
//! doors ran, and what a declaration that still writes it is told.
//!
//! # What the word decided, and why nothing is left of it
//!
//! A root's `dedup(hash)` / `dedup(eq)` picked the framework join its FUSED DOORS placed roots
//! through, and the `where` row those doors stated about the root parameter. The doors moved to
//! `#[ingraph::search]` — a recipe LISTS the members it fuses and carries its own `dedup(…)`, read
//! where the fold is minted — and the root's copy was left choosing nothing at all. An unpublished
//! word that decides nothing is DELETED rather than deprecated, which is this workspace's own law.
//!
//! # The sentence is a POINTER, not a roster line
//!
//! What is left in its place is a refusal that names `#[ingraph::search(dedup(hash))]`, because a
//! reader who wrote the word here wrote something that used to mean a real thing: the roster's
//! *unknown entry* would have sent them looking for a typo. The word is also OFF the near-miss
//! candidates, so nothing points at it either.
//!
//! Beside [`tests`](super::tests) on this directory's one-file-per-thing precedent, and it keeps the
//! file the retirement emptied rather than folding one test into a neighbour: the word has a history
//! here and this is where a reader looks for it.

use super::tests::{accepted, refused};

/// **BOTH SPELLINGS ARE REFUSED, AND THE SENTENCE NAMES WHERE THE WORD WENT.**
///
/// The two words the vocabulary ever had, and the bare and empty shapes beside them: whatever a
/// declaration writes, the answer is the same pointer, because what the retirement removed is the
/// WORD and not one of its readings.
#[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}",
    );
  }
}

/// **THE ROSTER NO LONGER OFFERS IT**, in either half: the sentence that lists a root's own words
/// names the four that decide something and not this one, and a near miss cannot suggest a word
/// that decides nothing.
#[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}",
  );
}

/// **THE REST OF THE HEAD IS UNTOUCHED** — a root that writes the two surviving words is accepted
/// exactly as it was, which is what makes the retirement a deletion rather than a rewrite.
#[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);
}