ingraph-codegen 0.1.0

The emission engine behind ingraph-derive: a plain declaration model in, the ingraph framework faces out.
Documentation
//! The composed model's own two answers: the fold a slot's name takes, and the schema name a
//! declaration that renames nothing publishes.

use quote::format_ident;

use super::*;

/// The HOUSEHOLD FOLD, at the four shapes a slot name comes in — the keyword slot spelled both
/// legal Rust ways, and the multi-word ones.
#[test]
fn a_slot_name_folds_the_way_every_other_wire_member_does() {
  let fold = |name: &str| wire_name(&format_ident!("{name}"));

  assert_eq!(fold("eq"), "eq");
  assert_eq!(fold("not_in"), "notIn");
  assert_eq!(fold("starts_with"), "startsWith");
  assert_eq!(fold("not_contains_nocase"), "notContainsNocase");
  // The keyword slot: a trailing underscore is Rust's other escape for it, and both land on `in`.
  assert_eq!(fold("in_"), "in");
  assert_eq!(
    wire_name(&syn::Ident::new_raw("in", proc_macro2::Span::call_site())),
    "in"
  );
}

/// The subject IS the filter, so the default schema name is its own — no suffix, and a raw prefix
/// dropped.
#[test]
fn the_default_schema_name_is_the_subjects_own() {
  assert_eq!(
    default_sdl_name(&format_ident!("RateFilter")).external(),
    "RateFilter"
  );
  assert_eq!(
    default_sdl_name(&syn::Ident::new_raw(
      "Where",
      proc_macro2::Span::call_site()
    ))
    .external(),
    "Where"
  );
}