use ingraph_codegen::{
enumeration::{EnumModel, EnumVariant, IntegerWidth, Namespace, StorageForm},
model::GraphqlKind,
};
use quote::ToTokens as _;
fn parse(input: &syn::DeriveInput) -> syn::Result<ingraph_codegen::enumeration::EnumModel> {
super::parse(input)
}
fn variants(model: &EnumModel) -> Vec<String> {
model
.variants
.iter()
.map(|variant| variant.ident.to_string())
.collect()
}
fn spelled(model: &EnumModel, namespace: Namespace) -> Vec<String> {
model
.variants
.iter()
.map(|variant| variant.name(namespace))
.collect()
}
fn rendered(path: &syn::Path) -> String {
path.to_token_stream().to_string().replace(' ', "")
}
fn accepted(input: &syn::DeriveInput) -> EnumModel {
parse(input).expect("the declaration is accepted")
}
fn refusal(input: &syn::DeriveInput) -> String {
parse(input)
.expect_err("the declaration is refused")
.into_iter()
.map(|error| error.to_string())
.collect::<Vec<_>>()
.join(" | ")
}
#[test]
fn a_bare_vocabulary_stores_numbers_and_shows_names() {
let model = parse(&syn::parse_quote! {
pub enum Codec { H264, Vp9, Av1 }
})
.expect("unit variants and nothing else is the whole shape");
assert_eq!(model.name, "Codec");
assert_eq!(variants(&model), ["H264", "Vp9", "Av1"]);
assert_eq!(rendered(&model.krate), "::ingraph");
assert!(model.forms.is_empty());
for namespace in [
Namespace::Sqlite,
Namespace::Postgres,
Namespace::Mysql,
Namespace::Mongo,
] {
assert_eq!(model.form(namespace), StorageForm::Integer);
}
assert_eq!(model.form(Namespace::Graphql), StorageForm::Text);
assert_eq!(model.width(), IntegerWidth::I64);
}
#[test]
fn one_face_takes_a_form_without_moving_the_others() {
let model = parse(&syn::parse_quote! {
#[ingraph(postgres(text), graphql(integer))]
enum Codec { H264 }
})
.expect("a face states its own form");
assert_eq!(model.form(Namespace::Postgres), StorageForm::Text);
assert_eq!(model.form(Namespace::Graphql), StorageForm::Integer);
assert_eq!(model.form(Namespace::Sqlite), StorageForm::Integer);
}
#[test]
fn a_face_block_may_carry_no_form_at_all() {
for input in [
syn::parse_quote! {
#[ingraph(mysql)]
enum Codec { H264 }
},
syn::parse_quote! {
#[ingraph(mysql())]
enum Codec { H264 }
},
] {
let model = parse(&input).expect("a face named and left at its default");
assert_eq!(model.form(Namespace::Mysql), StorageForm::Integer);
}
}
#[test]
fn the_width_is_read_off_the_repr() {
for width in IntegerWidth::ALL {
let word = syn::Ident::new(width.as_str(), proc_macro2::Span::call_site());
let model = parse(&syn::parse_quote! {
#[repr(#word)]
enum Grade { Low }
})
.expect("every width the framework carries is one a declaration may write");
assert_eq!(model.width, Some(width), "{}", width.as_str());
}
}
#[test]
fn a_layout_repr_is_not_a_width() {
let model = parse(&syn::parse_quote! {
#[repr(C)]
enum Grade { Low }
})
.expect("`repr(C)` is a fact about layout");
assert_eq!(model.width, None);
assert_eq!(model.width(), IntegerWidth::I64);
}
#[test]
fn the_crate_path_overrides_the_default() {
let model = parse(&syn::parse_quote! {
#[ingraph(crate = "shim::ingraph")]
enum Codec { H264 }
})
.expect("a re-export shim is a path like any other");
assert_eq!(rendered(&model.krate), "shim::ingraph");
}
#[test]
fn a_declared_discriminant_does_not_disturb_the_parse() {
let model = parse(&syn::parse_quote! {
enum Grade { Low = 3, High = 9 }
})
.expect("an explicit discriminant is still a unit variant");
assert_eq!(variants(&model), ["Low", "High"]);
}
#[test]
fn a_global_rename_moves_every_face_that_stated_none() {
let model = parse(&syn::parse_quote! {
#[ingraph(sqlite(text), postgres(text))]
enum Grade {
#[ingraph(rename = "lo", postgres(rename = "LO"), graphql(rename = "LOW"))]
Low,
High,
}
})
.expect("a variant states its words");
assert_eq!(model.variants[0].canonical(), "lo");
assert_eq!(spelled(&model, Namespace::Sqlite), ["lo", "High"]);
assert_eq!(spelled(&model, Namespace::Postgres), ["LO", "High"]);
assert_eq!(spelled(&model, Namespace::Graphql), ["LOW", "HIGH"]);
}
#[test]
fn the_refusal_type_is_named_by_the_declaration_or_by_the_convention() {
let named = parse(&syn::parse_quote! {
#[ingraph(error(rename = "NoSuchCodec"))]
enum Codec { H264 }
})
.expect("a vocabulary may name the one type it emits");
assert_eq!(named.error, Some(syn::parse_quote!(NoSuchCodec)));
assert_eq!(named.error(), "NoSuchCodec");
let defaulted = parse(&syn::parse_quote! {
enum Codec { H264 }
})
.expect("and a declaration that says nothing keeps the convention");
assert_eq!(defaulted.error, None);
assert_eq!(defaulted.error(), "CodecParseError");
}
#[test]
fn a_refusal_may_be_named_with_a_raw_identifier() {
let model = parse(&syn::parse_quote! {
#[ingraph(error(rename = "r#type"))]
enum Codec { H264 }
})
.expect("`r#type` is an identifier");
assert_eq!(model.error(), "r#type");
}
#[test]
fn refuses_a_refusal_named_after_the_vocabulary() {
let refused = refusal(&syn::parse_quote! {
#[ingraph(error(rename = "Codec"))]
enum Codec { H264 }
});
assert!(
refused.contains("already the vocabulary's own name"),
"{refused}"
);
}
#[test]
fn refuses_a_refusal_name_that_is_not_an_identifier() {
for spelling in ["", "Not An Ident", "9Lives"] {
let refused = refusal(&syn::parse_quote! {
#[ingraph(error(rename = #spelling))]
enum Codec { H264 }
});
assert!(
refused.contains("must be a valid identifier"),
"{spelling:?}: {refused}"
);
}
}
#[test]
fn refuses_an_error_block_that_names_nothing() {
for input in [
syn::parse_quote! {
#[ingraph(error)]
enum Codec { H264 }
},
syn::parse_quote! {
#[ingraph(error())]
enum Codec { H264 }
},
] {
let refused = refusal(&input);
assert!(
refused.contains("`error(…)` needs `rename = \"…\"`"),
"{refused}"
);
}
let twice = refusal(&syn::parse_quote! {
#[ingraph(error(rename = "A", rename = "B"))]
enum Codec { H264 }
});
assert!(
twice.contains("declared more than once in `error(…)`"),
"{twice}"
);
let stray = refusal(&syn::parse_quote! {
#[ingraph(error(text))]
enum Codec { H264 }
});
assert!(stray.contains("unknown entry in `error(…)`"), "{stray}");
}
#[test]
fn refuses_a_declaration_that_is_not_an_enum() {
let refused = refusal(&syn::parse_quote! {
struct Codec { name: String }
});
assert!(refused.contains("supports enums only"), "{refused}");
}
#[test]
fn refuses_an_enum_with_no_variants() {
let refused = refusal(&syn::parse_quote! {
enum Codec {}
});
assert!(refused.contains("declares no vocabulary"), "{refused}");
}
#[test]
fn refuses_every_variant_that_carries_data() {
let refused = refusal(&syn::parse_quote! {
enum Shape { Unit, Tuple(u8), Named { width: u8 } }
});
assert!(refused.contains("`Tuple` carries data"), "{refused}");
assert!(refused.contains("`Named` carries data"), "{refused}");
}
#[test]
fn refuses_a_generic_vocabulary() {
let refused = refusal(&syn::parse_quote! {
enum Codec<T> { H264, Vp9 }
});
assert!(refused.contains("generic vocabularies"), "{refused}");
}
#[test]
fn refuses_a_lifetime_and_a_where_clause_for_the_same_reason() {
let by_lifetime = refusal(&syn::parse_quote! {
enum Codec<'a> { H264 }
});
assert!(
by_lifetime.contains("generic vocabularies"),
"{by_lifetime}"
);
let by_clause = refusal(&syn::parse_quote! {
enum Codec where Self: Sized { H264 }
});
assert!(by_clause.contains("generic vocabularies"), "{by_clause}");
}
#[test]
fn refuses_a_rename_under_a_face_that_stores_the_discriminant() {
let by_default = refusal(&syn::parse_quote! {
enum Grade {
#[ingraph(sqlite(rename = "lo"))]
Low,
}
});
assert!(
by_default.contains("stores the discriminant"),
"{by_default}"
);
assert!(by_default.contains("by default"), "{by_default}");
let declared = refusal(&syn::parse_quote! {
#[ingraph(mysql(integer))]
enum Grade {
#[ingraph(mysql(rename = "lo"))]
Low,
}
});
assert!(declared.contains("as this declaration says"), "{declared}");
}
#[test]
fn refuses_two_variants_that_collide_in_one_namespace() {
let canonical = refusal(&syn::parse_quote! {
enum Grade {
#[ingraph(rename = "same")]
Low,
#[ingraph(rename = "same")]
High,
}
});
assert!(
canonical.contains("in the canonical namespace"),
"{canonical}"
);
let per_face = refusal(&syn::parse_quote! {
#[ingraph(postgres(text))]
enum Grade {
#[ingraph(postgres(rename = "same"))]
Low,
#[ingraph(postgres(rename = "same"))]
High,
}
});
assert!(
per_face.contains("in the `postgres` namespace"),
"{per_face}"
);
parse(&syn::parse_quote! {
#[ingraph(postgres(text))]
enum Grade {
#[ingraph(postgres(rename = "same"), graphql(rename = "SAME"))]
Low,
High,
}
})
.expect("one word per face per variant is the rule, and this keeps it");
}
#[test]
fn refuses_a_collision_the_wire_casing_creates() {
let refused = refusal(&syn::parse_quote! {
enum Codec { Vp9, VP9 }
});
assert!(refused.contains("are both `VP9` on the wire"), "{refused}");
}
#[test]
fn refuses_a_wire_collision_under_a_face_declared_integer() {
let refused = refusal(&syn::parse_quote! {
#[ingraph(graphql(integer))]
enum Codec { Vp9, VP9 }
});
assert!(refused.contains("are both `VP9` on the wire"), "{refused}");
}
#[test]
fn refuses_two_variants_that_derive_one_predicate() {
let refused = refusal(&syn::parse_quote! {
#[ingraph(graphql(integer))]
enum Codec { Vp9, VP9 }
});
assert!(refused.contains("both derive `is_vp9`"), "{refused}");
}
#[test]
fn refuses_a_wire_rename_that_is_not_a_graphql_name() {
let refused = refusal(&syn::parse_quote! {
enum Grade {
#[ingraph(graphql(rename = "low grade"))]
Low,
}
});
assert!(refused.contains("is not a GraphQL name"), "{refused}");
}
#[test]
fn refuses_a_repr_width_no_dialect_can_carry() {
for word in IntegerWidth::UNCARRIED {
let repr = syn::Ident::new(word, proc_macro2::Span::call_site());
let refused = refusal(&syn::parse_quote! {
#[repr(#repr)]
enum Grade { Low }
});
assert!(refused.contains("not a width a vocabulary"), "{refused}");
}
parse(&syn::parse_quote! {
#[repr(u64)]
#[ingraph(sqlite(text), postgres(text), mysql(text), mongo(text))]
enum Grade { Low }
})
.expect("a vocabulary stored as text everywhere renders no discriminant");
}
#[test]
fn refuses_a_word_no_form_answers_to() {
let refused = refusal(&syn::parse_quote! {
#[ingraph(sqlite(blob))]
enum Codec { H264 }
});
assert!(
refused.contains("unknown entry in `sqlite(…)`"),
"{refused}"
);
}
#[test]
fn refuses_two_forms_in_one_face() {
let refused = refusal(&syn::parse_quote! {
#[ingraph(sqlite(text, integer))]
enum Codec { H264 }
});
assert!(refused.contains("a face takes ONE form"), "{refused}");
}
#[test]
fn refuses_a_repeated_face_block() {
let on_the_enum = refusal(&syn::parse_quote! {
#[ingraph(sqlite(text), sqlite(integer))]
enum Codec { H264 }
});
assert!(
on_the_enum.contains("declared more than once"),
"{on_the_enum}"
);
let on_a_variant = refusal(&syn::parse_quote! {
#[ingraph(sqlite(text))]
enum Codec {
#[ingraph(sqlite(rename = "a"), sqlite(rename = "b"))]
H264,
}
});
assert!(
on_a_variant.contains("declared more than once on this variant"),
"{on_a_variant}"
);
}
#[test]
fn refuses_an_entry_a_vocabulary_does_not_take() {
let on_the_enum = refusal(&syn::parse_quote! {
#[ingraph(persist(sqlite))]
enum Codec { H264 }
});
assert!(on_the_enum.contains("unknown entry"), "{on_the_enum}");
assert!(on_the_enum.contains("`sqlite`"), "{on_the_enum}");
let on_a_variant = refusal(&syn::parse_quote! {
enum Codec {
#[ingraph(skip)]
H264,
}
});
assert!(
on_a_variant.contains("unknown entry in `#[ingraph(…)]` on a variant"),
"{on_a_variant}"
);
let in_a_face = refusal(&syn::parse_quote! {
#[ingraph(sqlite(text))]
enum Codec {
#[ingraph(sqlite(type = "String"))]
H264,
}
});
assert!(
in_a_face.contains("unknown entry in `sqlite(…)` on a variant"),
"{in_a_face}"
);
}
#[test]
fn one_pass_reports_the_grammar_and_the_shape_together() {
let refused = refusal(&syn::parse_quote! {
#[ingraph(sqlite(blob))]
enum Shape { Tuple(u8) }
});
assert!(
refused.contains("unknown entry in `sqlite(…)`"),
"{refused}"
);
assert!(refused.contains("`Tuple` carries data"), "{refused}");
}
#[test]
fn a_raw_variant_keeps_its_spelling_and_loses_its_escape() {
let model = parse(&syn::parse_quote! {
enum Codec { r#type }
})
.expect("a raw identifier is a variant like any other");
let variant: &EnumVariant = &model.variants[0];
assert_eq!(variant.ident.to_string(), "r#type");
assert_eq!(variant.canonical(), "type");
assert_eq!(variant.predicate(), "is_type");
}
#[test]
fn a_bare_declaration_shouts_every_wire_value() {
let model = parse(&syn::parse_quote! {
pub enum Codec { H264, Vp9, Av1 }
})
.expect("unit variants and nothing else is the whole shape");
assert_eq!(spelled(&model, Namespace::Graphql), ["H264", "VP9", "AV1"]);
}
#[test]
fn both_rename_axes_move_the_wire_word() {
let model = parse(&syn::parse_quote! {
pub enum Channel {
#[ingraph(rename = "mono")]
Mono,
#[ingraph(graphql(rename = "TWO_CHANNEL"))]
Stereo,
#[ingraph(rename = "sur", graphql(rename = "SURROUND_5_1"))]
Surround,
}
})
.expect("both axes are the vocabulary's own words");
assert_eq!(
spelled(&model, Namespace::Graphql),
["MONO", "TWO_CHANNEL", "SURROUND_5_1"],
"the canonical word is what the default casing is applied TO, and a face's own word wins"
);
}
#[test]
fn a_raw_name_loses_only_its_escape_on_the_wire() {
let model = parse(&syn::parse_quote! {
pub enum r#Match { r#Type, r#Move }
})
.expect("a raw identifier is a name like any other");
assert_eq!(spelled(&model, Namespace::Graphql), ["TYPE", "MOVE"]);
}
#[test]
fn a_wire_name_must_be_a_graphql_name() {
let variant = refusal(&syn::parse_quote! {
pub enum Codec {
#[ingraph(graphql(rename = "h-264"))]
H264,
}
});
assert!(
variant.contains("`h-264` is not a GraphQL name"),
"{variant}"
);
let named = refusal(&syn::parse_quote! {
pub enum Codéc { H264 }
});
assert!(named.contains("is not a GraphQL name"), "{named}");
}
#[test]
fn one_door_emits_the_storage_rows_and_the_wire_face() {
let model = parse(&syn::parse_quote! {
pub enum Channel { Mono, Stereo }
})
.expect("the one door");
let emitted = model.emit().to_string();
for row in ["EnumFilterMarker", "DefaultMarker", "CursorValue"] {
assert!(emitted.contains(row), "`{row}` is missing:\n{emitted}");
}
for face in ["if_async_graphql", "InputType", "EnumType"] {
assert!(emitted.contains(face), "`{face}` is missing:\n{emitted}");
}
assert_eq!(
emitted.matches("if_async_graphql").count(),
1,
"the wire face is ONE gated block:\n{emitted}"
);
}
#[test]
fn the_wire_face_carries_the_declarations_own_words() {
let model = parse(&syn::parse_quote! {
#[ingraph(sqlite(text))]
pub enum Channel {
#[ingraph(rename = "mono", sqlite(rename = "m"), graphql(rename = "MONAURAL"))]
Mono,
Stereo,
r#Type,
}
})
.expect("every axis at once");
let emitted = model.emit().to_string();
for word in ["\"MONAURAL\"", "\"STEREO\"", "\"TYPE\"", "\"m\""] {
assert!(emitted.contains(word), "`{word}` is missing:\n{emitted}");
}
}
fn mirrored(model: &EnumModel) -> String {
rendered(&model.remote.as_ref().expect("the declaration mirrors").path)
}
#[test]
fn a_mirror_names_its_upstream_and_restates_its_variants() {
let model = parse(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat")]
pub enum PixelFormat {
Yuv420p,
Rgb24,
}
})
.expect("a restatement and the word that says whose");
assert_eq!(mirrored(&model), "mediaframe::PixelFormat");
assert_eq!(variants(&model), ["Yuv420p", "Rgb24"]);
assert!(model.escape().is_none(), "no escape was declared");
for variant in &model.variants {
assert_eq!(
variant.upstream(),
variant.ident,
"spelled alike by default"
);
}
}
#[test]
fn a_renamed_variant_restates_a_differently_spelled_upstream() {
let model = parse(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat")]
pub enum PixelFormat {
#[ingraph(rename = "Rgb888")]
Rgb24,
}
})
.expect("a rename names the upstream");
assert_eq!(model.variants[0].upstream(), "Rgb888");
assert!(
model.variants[0].rename.is_none(),
"and it moves no canonical word, a mirror having none"
);
}
#[test]
fn the_escape_is_the_marked_variant_and_its_name_is_free() {
let model = parse(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat")]
pub enum PixelFormat {
Rgb24,
#[ingraph(other)]
Unknown(::ingraph::Utf8Bytes),
}
})
.expect("a marked escape");
let escape = model.escape().expect("the marker found it");
assert_eq!(escape.ident, "Unknown");
assert_eq!(
model.restated().count(),
1,
"the escape restates no upstream variant"
);
}
#[test]
fn delegated_signatures_are_carried_verbatim() {
let model = parse(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat", delegate(
fn is_planar(&self) -> bool,
fn bits_per_component(&self, plane: usize) -> u8,
))]
pub enum PixelFormat {
Rgb24,
}
})
.expect("two borrowed methods");
let delegates = &model.remote.as_ref().expect("a mirror").delegates;
assert_eq!(delegates.len(), 2);
assert_eq!(delegates[0].signature.ident, "is_planar");
assert_eq!(delegates[1].signature.ident, "bits_per_component");
}
#[test]
fn a_closed_mirror_still_names_its_refusal() {
let model = parse(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat", error(rename = "NoSuchFormat"))]
pub enum PixelFormat {
Rgb24,
}
})
.expect("a closed mirror refuses, and names the refusal");
assert_eq!(model.error(), "NoSuchFormat");
}
#[test]
fn an_open_mirror_has_no_refusal_type_for_the_knob_to_move() {
for door in ["other", "other(from = \"mediaframe::PixelFormat::other\")"] {
let cell: syn::Meta = syn::parse_str(door).expect("a marker");
let refused = refusal(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat", error(rename = "NoSuchFormat"))]
pub enum PixelFormat {
Rgb24,
#[ingraph(#cell)]
Other(::ingraph::Utf8Bytes),
}
});
assert!(
refused.contains("this mirror has none"),
"{door}: {refused}"
);
assert!(
refused.contains("`other(try_from = \"…\")` is the posture whose door CAN refuse"),
"and the sentence names the posture the knob IS for — {door}: {refused}"
);
}
}
#[test]
fn a_refusable_gate_may_name_its_refusal() {
let model = parse(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat", error(rename = "NoSuchFormat"))]
pub enum PixelFormat {
Rgb24,
#[ingraph(other(try_from = "mediaframe::PixelFormat::try_other"))]
Other(::ingraph::Utf8Bytes),
}
})
.expect("a half-open mirror casts a refusal type, so the knob has one to move");
assert_eq!(model.error(), "NoSuchFormat");
assert!(model.refuses(), "and the parse can refuse");
}
#[test]
fn the_escape_opens_one_of_two_doors() {
for (door, gate, refuses) in [
("from", "mediaframe::PixelFormat::other", false),
("try_from", "mediaframe::PixelFormat::try_other", true),
] {
let cell: syn::Meta = syn::parse_str(&format!("other({door} = \"{gate}\")")).expect("a cell");
let model = parse(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat")]
pub enum PixelFormat {
Rgb24,
#[ingraph(#cell)]
Other(::ingraph::Utf8Bytes),
}
})
.expect("a gated escape");
let posture = model.posture().expect("the marker found it");
assert_eq!(
posture
.gate()
.map(|path| quote::quote!(#path).to_string().replace(' ', "")),
Some(gate.to_owned()),
"{door} names the gate"
);
assert_eq!(posture.refuses(), refuses, "{door}");
assert_eq!(model.refuses(), refuses, "and the mirror follows it");
}
}
#[test]
fn a_bare_escape_still_reads_the_upstreams_type() {
let model = parse(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat")]
pub enum PixelFormat {
Rgb24,
#[ingraph(other)]
Other(::ingraph::Utf8Bytes),
}
})
.expect("a bare escape");
let posture = model.posture().expect("the marker found it");
assert!(posture.gate().is_none(), "no gate to name");
assert!(!posture.refuses(), "and the mirror is open");
}
#[test]
fn the_escape_opens_one_door_and_not_two() {
let refused = refusal(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat")]
pub enum PixelFormat {
Rgb24,
#[ingraph(other(from = "a::b", try_from = "c::d"))]
Other(::ingraph::Utf8Bytes),
}
});
assert!(
refused.contains("are both declared on this escape"),
"{refused}"
);
assert!(refused.contains("there is no third answer"), "{refused}");
}
#[test]
fn an_empty_cell_names_no_door() {
let refused = refusal(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat")]
pub enum PixelFormat {
Rgb24,
#[ingraph(other())]
Other(::ingraph::Utf8Bytes),
}
});
assert!(
refused.contains("An empty block names neither"),
"{refused}"
);
}
#[test]
fn the_escapes_cell_is_a_block_and_not_a_value() {
let refused = refusal(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat")]
pub enum PixelFormat {
Rgb24,
#[ingraph(other = "mediaframe::PixelFormat::other")]
Other(::ingraph::Utf8Bytes),
}
});
assert!(refused.contains("it carries a BLOCK"), "{refused}");
}
#[test]
fn a_cell_takes_the_two_words_it_knows() {
let refused = refusal(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat")]
pub enum PixelFormat {
Rgb24,
#[ingraph(other(via = "a::b"))]
Other(::ingraph::Utf8Bytes),
}
});
assert!(refused.contains("an escape opens ONE door"), "{refused}");
}
#[test]
fn a_gate_is_a_path_in_a_string() {
let refused = refusal(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat")]
pub enum PixelFormat {
Rgb24,
#[ingraph(other(from = 7))]
Other(::ingraph::Utf8Bytes),
}
});
assert!(
refused.contains("take a PATH to the gate function"),
"{refused}"
);
}
#[test]
fn a_celled_escape_on_a_declaration_with_no_upstream_names_the_absent_upstream() {
for cell in [
quote::quote!(other(from = "a::b")),
quote::quote!(other(try_from = "a::b")),
] {
let refused = refusal(&syn::parse_quote! {
pub enum Codec {
H264,
#[ingraph(#cell)]
Other(::ingraph::Utf8Bytes),
}
});
assert!(
refused.contains("this declaration has no upstream"),
"{refused}"
);
assert!(
refused.contains("BARE `#[ingraph(other)]` is the whole marker here"),
"{refused}"
);
}
}
#[test]
fn the_escape_marker_opens_a_vocabulary_of_this_crates_own() {
let model = accepted(&syn::parse_quote! {
pub enum BodyJoint {
Nose,
LeftShoulder,
#[ingraph(other)]
Other(::ingraph::Utf8Bytes),
}
});
assert!(model.remote.is_none(), "it mirrors nothing");
assert_eq!(
model.escape().map(|escape| escape.ident.to_string()),
Some("Other".to_owned())
);
assert!(!model.refuses(), "an open door cannot refuse");
assert_eq!(
model
.restated()
.map(EnumVariant::folded)
.collect::<Vec<_>>(),
["nose", "left_shoulder"],
"and the words are the household fold of the Rust names"
);
}
#[test]
fn an_open_vocabularys_rename_names_a_word_rather_than_an_upstream_variant() {
let model = accepted(&syn::parse_quote! {
pub enum Symbology {
#[ingraph(rename = "i2of5")]
InterleavedTwoOfFive,
#[ingraph(other)]
Other(::ingraph::Utf8Bytes),
}
});
assert_eq!(
model
.restated()
.map(EnumVariant::folded)
.collect::<Vec<_>>(),
["i2of5"]
);
}
#[test]
fn an_open_vocabulary_takes_one_escape_and_refuses_a_second() {
let refused = refusal(&syn::parse_quote! {
pub enum BodyJoint {
Nose,
#[ingraph(other)]
Other(::ingraph::Utf8Bytes),
#[ingraph(other)]
Unknown(::ingraph::Utf8Bytes),
}
});
assert!(
refused.contains("`Unknown` and `Other` are both marked"),
"{refused}"
);
assert!(refused.contains("a vocabulary has ONE escape"), "{refused}");
}
#[test]
fn an_open_vocabulary_names_no_form_and_spells_no_face() {
let refused = refusal(&syn::parse_quote! {
#[ingraph(sqlite(integer))]
pub enum BodyJoint {
#[ingraph(graphql(rename = "NOSE"))]
Nose,
#[ingraph(other)]
Other(::ingraph::Utf8Bytes),
}
});
assert!(
refused.contains("an OPEN vocabulary has none to name"),
"{refused}"
);
assert!(
refused.contains("an OPEN vocabulary spells it one way everywhere"),
"{refused}"
);
}
#[test]
fn an_open_vocabulary_has_no_refusal_type_for_the_knob_to_move() {
let refused = refusal(&syn::parse_quote! {
#[ingraph(error(rename = "NoSuchJoint"))]
pub enum BodyJoint {
Nose,
#[ingraph(other)]
Other(::ingraph::Utf8Bytes),
}
});
assert!(refused.contains("this vocabulary has none"), "{refused}");
assert!(refused.contains("Drop the escape"), "{refused}");
}
#[test]
fn an_open_vocabularys_escape_carries_its_word_rather_than_spelling_one() {
let refused = refusal(&syn::parse_quote! {
pub enum BodyJoint {
Nose,
#[ingraph(other, rename = "unknown")]
Other(::ingraph::Utf8Bytes),
}
});
assert!(
refused.contains("the escape has no canonical word for `rename` to move"),
"{refused}"
);
}
#[test]
fn two_members_of_one_roster_may_not_spell_one_word() {
let refused = refusal(&syn::parse_quote! {
pub enum BodyJoint {
Nose,
#[ingraph(rename = "nose")]
Snout,
#[ingraph(other)]
Other(::ingraph::Utf8Bytes),
}
});
assert!(
refused.contains("`Snout` and `Nose` are both `nose`"),
"{refused}"
);
}
#[test]
fn a_roster_names_its_members_and_carries_one_word() {
let refused = refusal(&syn::parse_quote! {
pub enum BodyJoint {
Nose,
Extra(u8),
#[ingraph(other)]
Other(::ingraph::Utf8Bytes),
}
});
assert!(
refused.contains("this vocabulary already has its escape"),
"{refused}"
);
}
#[test]
fn a_payload_variant_in_a_closed_vocabulary_is_told_about_the_marker_it_forgot() {
let refused = refusal(&syn::parse_quote! {
pub enum BodyJoint {
Nose,
Other(::ingraph::Utf8Bytes),
}
});
assert!(
refused.contains("`#[ingraph(other)]` on this variant is what says so"),
"{refused}"
);
assert!(
refused.contains("`#[derive(ingraph::Union)]` is the word for one"),
"and the other road is still named: {refused}"
);
}
#[test]
fn a_mirror_takes_one_escape_and_refuses_a_second() {
let refused = refusal(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat")]
pub enum PixelFormat {
#[ingraph(other)]
Other(::ingraph::Utf8Bytes),
#[ingraph(other)]
Unknown(::ingraph::Utf8Bytes),
}
});
assert!(
refused.contains("`Unknown` and `Other` are both marked"),
"{refused}"
);
}
#[test]
fn the_escape_cannot_also_be_renamed() {
let refused = refusal(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat")]
pub enum PixelFormat {
#[ingraph(other, rename = "Unknown")]
Other(::ingraph::Utf8Bytes),
}
});
assert!(
refused.contains("the escape mirrors no upstream variant"),
"{refused}"
);
}
#[test]
fn the_escape_carries_exactly_one_unnamed_field() {
for shape in [
quote::quote!(Other),
quote::quote!(Other(::ingraph::Utf8Bytes, u8)),
quote::quote!(Other {
word: ::ingraph::Utf8Bytes
}),
] {
let refused = refusal(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat")]
pub enum PixelFormat {
Rgb24,
#[ingraph(other)]
#shape,
}
});
assert!(
refused.contains("must carry EXACTLY ONE unnamed field"),
"{shape}: {refused}"
);
}
}
#[test]
fn a_restated_variant_carries_no_payload() {
let refused = refusal(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat")]
pub enum PixelFormat {
Rgb24(u8),
}
});
assert!(
refused.contains("A mirror RESTATES its upstream's variants"),
"{refused}"
);
}
#[test]
fn a_mirror_takes_no_face_block() {
let enum_level = refusal(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat", sqlite(text))]
pub enum PixelFormat {
Rgb24,
}
});
assert!(
enum_level.contains("names a FORM for one face"),
"{enum_level}"
);
let variant_level = refusal(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat")]
pub enum PixelFormat {
#[ingraph(graphql(rename = "RGB24"))]
Rgb24,
}
});
assert!(
variant_level.contains("a mirror spells it one way everywhere"),
"{variant_level}"
);
}
#[test]
fn a_declaration_that_mirrors_nothing_delegates_nothing() {
let refused = refusal(&syn::parse_quote! {
#[ingraph(delegate(fn is_planar(&self) -> bool))]
pub enum Codec { H264 }
});
assert!(
refused.contains("forwards a method onto a MIRRORED upstream value"),
"{refused}"
);
}
#[test]
fn the_full_form_carries_the_target_on_its_own_entry() {
let model = accepted(&syn::parse_quote! {
#[ingraph(
remote = "mediaframe::PixelFormat",
delegate(fn is_planar(&self) -> bool),
delegate(
#[graphql(async_graphql(rename = "depth"))]
signature = fn bit_depth(&self) -> u32,
on = self,
),
)]
pub enum PixelFormat { Rgb24 }
});
let delegates = &model.remote.as_ref().expect("a mirror").delegates;
assert_eq!(delegates.len(), 2);
assert_eq!(delegates[0].signature.ident, "is_planar");
assert!(
delegates[0].on_self.is_none(),
"a shorthand entry waives nothing"
);
assert_eq!(delegates[1].signature.ident, "bit_depth");
assert!(
delegates[1].on_self.is_some(),
"and the full form's own carries the word"
);
assert_eq!(
delegates[1].word(GraphqlKind::AsyncGraphql).as_deref(),
Some("depth"),
"the PROMOTED half is untouched by the waiver — the resolver's arm is a qualified call on the \
mirror either way"
);
assert_eq!(
model.promoted(GraphqlKind::AsyncGraphql).count(),
1,
"and the promotion law reads `wire`, which the property does not touch"
);
}
#[test]
fn the_mirrors_mount_reaches_the_shared_grammar() {
let mixed = refusal(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat", delegate(
fn is_planar(&self) -> bool,
on = self,
))]
pub enum PixelFormat { Rgb24 }
});
assert!(mixed.contains("written in ONE of two spellings"), "{mixed}");
let target = refusal(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat", delegate(
signature = fn is_planar(&self) -> bool,
on = upstream,
))]
pub enum PixelFormat { Rgb24 }
});
assert!(
target.contains("`on = upstream` names no target"),
"{target}"
);
assert!(
target.contains("`on` takes `self`, and `self` is the whole of it"),
"and the roster is named: {target}"
);
}
#[test]
fn a_waived_entry_publishes_or_it_says_nothing() {
let refused = refusal(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat", delegate(
signature = fn bit_depth(&self) -> u32,
on = self,
))]
pub enum PixelFormat { Rgb24 }
});
assert!(
refused.contains("`on = self` waives its forwarding half, so the entry has no reader"),
"{refused}"
);
let shorthand = accepted(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat", delegate(fn is_planar(&self) -> bool))]
pub enum PixelFormat { Rgb24 }
});
assert_eq!(
shorthand.remote.as_ref().expect("a mirror").delegates.len(),
1,
"and an unpublished entry that wrote NO property still mints, so it still has one"
);
}
#[test]
fn a_delegate_may_not_take_a_variants_predicate() {
let refused = refusal(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat", delegate(fn is_bayer(&self) -> bool))]
pub enum PixelFormat { Rgb24, Bayer }
});
assert!(
refused.contains("would declare `is_bayer` twice"),
"{refused}"
);
assert!(
refused.contains("the `Bayer` variant's predicate"),
"the sentence names WHICH variant: {refused}"
);
assert!(
refused.contains("the delegated `is_bayer`"),
"and which side is the author's: {refused}"
);
}
#[test]
fn a_waived_entry_may_not_take_a_variants_predicate_either() {
let refused = refusal(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat", delegate(
#[graphql(async_graphql)]
signature = fn is_bayer(&self) -> bool,
on = self,
))]
pub enum PixelFormat { Rgb24, Bayer }
});
assert!(
refused.contains("would declare `is_bayer` twice"),
"{refused}"
);
assert!(
refused.contains("the `Bayer` variant's predicate"),
"{refused}"
);
}
#[test]
fn a_delegate_may_not_take_the_modes_own_words() {
let gate = refusal(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat", delegate(fn remote(&self) -> u8))]
pub enum PixelFormat { Rgb24 }
});
assert!(gate.contains("would declare `remote` twice"), "{gate}");
assert!(
gate.contains("the mirror's own upstream materialization"),
"{gate}"
);
let roster = refusal(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat", delegate(fn VARIANTS(&self) -> u8))]
pub enum PixelFormat { Rgb24 }
});
assert!(
roster.contains("would declare `VARIANTS` twice"),
"{roster}"
);
assert!(
roster.contains("the mirror's own restated-variant roster"),
"{roster}"
);
}
#[test]
fn two_delegate_entries_may_not_share_a_name() {
let refused = refusal(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat", delegate(
fn planar(&self) -> bool,
fn planar(&self) -> u8,
))]
pub enum PixelFormat { Rgb24 }
});
assert!(
refused.contains("would declare `planar` twice"),
"{refused}"
);
assert!(
refused.contains("the delegated `planar`, and the delegated `planar`"),
"both sides are entries: {refused}"
);
}
#[test]
fn two_variants_folding_to_one_predicate_are_still_the_variants_rule() {
let refused = refusal(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat")]
pub enum PixelFormat { Rgb24, RGB24 }
});
assert!(refused.contains("both derive `is_rgb24`"), "{refused}");
assert!(
!refused.contains("would declare `is_rgb24` twice"),
"and the collision walk says nothing about it: {refused}"
);
}
#[test]
fn a_near_miss_of_an_emitted_name_still_compiles() {
let model = accepted(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat", delegate(
fn is_bayer2(&self) -> bool,
fn bayer(&self) -> bool,
fn remotes(&self) -> u8,
fn variants(&self) -> u8,
))]
pub enum PixelFormat { Rgb24, Bayer }
});
assert_eq!(
model
.remote
.as_ref()
.expect("a mirror")
.delegates
.iter()
.map(|delegate| delegate.signature.ident.to_string())
.collect::<Vec<_>>(),
["is_bayer2", "bayer", "remotes", "variants"]
);
}
#[test]
fn a_delegated_method_borrows_its_receiver() {
for signature in [
quote::quote!(fn into_upstream(self) -> u8),
quote::quote!(fn free() -> u8),
] {
let refused = refusal(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat", delegate(#signature))]
pub enum PixelFormat { Rgb24 }
});
assert!(
refused.contains("a delegated method BORROWS its receiver"),
"{signature}: {refused}"
);
}
}
#[test]
fn a_delegate_takes_a_shared_or_an_exclusive_borrow() {
let model = accepted(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat", delegate(
fn planar(&self) -> bool,
fn demote(&mut self) -> bool,
))]
pub enum PixelFormat { Rgb24 }
});
let delegates = &model.remote.as_ref().expect("a mirror").delegates;
assert_eq!(delegates.len(), 2);
assert!(!delegates[0].exclusive, "`&self` forwards");
assert!(delegates[1].exclusive, "`&mut self` writes back");
}
#[test]
fn a_published_entry_is_a_delegate_that_also_reaches_a_schema() {
let model = accepted(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat", delegate(
fn to_u32(&self) -> Option<u32>,
#[graphql(async_graphql)]
fn is_bayer(&self) -> bool,
#[graphql(async_graphql(rename = "bayer"))]
fn is_hdr(&self) -> bool,
))]
pub enum PixelFormat { Rgb24 }
});
let delegates = &model.remote.as_ref().expect("a mirror").delegates;
assert_eq!(delegates.len(), 3, "every entry is a method");
assert_eq!(
delegates[0].word(GraphqlKind::AsyncGraphql),
None,
"and the bare one publishes nothing"
);
assert_eq!(
delegates[1].word(GraphqlKind::AsyncGraphql).as_deref(),
Some("isBayer"),
"the default knob folds to lower camel case"
);
assert_eq!(
delegates[2].word(GraphqlKind::AsyncGraphql).as_deref(),
Some("bayer"),
"and `rename` is the word verbatim"
);
assert_eq!(
model.promoted(GraphqlKind::AsyncGraphql).count(),
2,
"two of the three promote this mirror"
);
}
#[test]
fn a_published_delegate_reads_its_receiver() {
let refused = refusal(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat", delegate(
#[graphql(async_graphql)]
fn demote(&mut self) -> bool,
))]
pub enum PixelFormat { Rgb24 }
});
assert!(
refused.contains("a published delegate takes `&self`"),
"{refused}"
);
}
#[test]
fn a_delegate_entry_wears_one_attribute_and_it_names_a_backend() {
let bare = refusal(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat", delegate(
#[graphql]
fn planar(&self) -> bool,
))]
pub enum PixelFormat { Rgb24 }
});
assert!(bare.contains("`#[graphql]` names no backend"), "{bare}");
let empty = refusal(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat", delegate(
#[graphql()]
fn planar(&self) -> bool,
))]
pub enum PixelFormat { Rgb24 }
});
assert!(empty.contains("`#[graphql]` names no backend"), "{empty}");
let foreign = refusal(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat", delegate(
#[inline]
fn planar(&self) -> bool,
))]
pub enum PixelFormat { Rgb24 }
});
assert!(
foreign.contains("a `delegate(…)` entry takes one attribute"),
"{foreign}"
);
}
#[test]
fn two_published_delegates_cannot_take_one_word() {
let slug = refusal(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat", delegate(
#[graphql(async_graphql(rename = "text"))]
fn slug(&self) -> bool,
))]
pub enum PixelFormat { Rgb24 }
});
assert!(slug.contains("this field would be called `text`"), "{slug}");
let twice = refusal(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat", delegate(
#[graphql(async_graphql)]
fn is_bayer(&self) -> bool,
#[graphql(async_graphql(rename = "isBayer"))]
fn bayer(&self) -> bool,
))]
pub enum PixelFormat { Rgb24 }
});
assert!(
twice.contains("two published methods are both called `isBayer`"),
"{twice}"
);
}
#[test]
fn a_published_delegate_takes_no_arguments() {
let refused = refusal(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat", delegate(
#[graphql(async_graphql)]
fn wider_than(&self, other: u32) -> bool,
))]
pub enum PixelFormat { Rgb24 }
});
assert!(
refused.contains("takes its receiver and nothing else"),
"{refused}"
);
let accepted = accepted(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat", delegate(
fn wider_than(&self, other: u32) -> bool,
))]
pub enum PixelFormat { Rgb24 }
});
assert_eq!(
accepted.promoted(GraphqlKind::AsyncGraphql).count(),
0,
"and it promotes nothing"
);
}
#[test]
fn two_variants_cannot_mirror_one_upstream_variant() {
let refused = refusal(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat")]
pub enum PixelFormat {
Rgb24,
#[ingraph(rename = "Rgb24")]
Rgb888,
}
});
assert!(refused.contains("both restate `Rgb24`"), "{refused}");
}
#[test]
fn a_mirror_of_a_struct_is_refused_as_a_mirror() {
let refused = refusal(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat")]
pub struct PixelFormat(mediaframe::PixelFormat);
});
assert!(
refused.contains("a mirror RESTATES its upstream's"),
"{refused}"
);
}
#[test]
fn the_mirrors_own_words_are_read_as_what_they_name() {
let path = refusal(&syn::parse_quote! {
#[ingraph(remote = "not a path!")]
pub enum PixelFormat { Rgb24 }
});
assert!(path.contains("must be a path to the vocabulary"), "{path}");
let twice = refusal(&syn::parse_quote! {
#[ingraph(remote = "a::One", remote = "a::Two")]
pub enum PixelFormat { Rgb24 }
});
assert!(
twice.contains("one declaration mirrors one vocabulary"),
"{twice}"
);
let word = refusal(&syn::parse_quote! {
#[ingraph(remote = "mediaframe::PixelFormat")]
pub enum PixelFormat {
#[ingraph(rename = "rgb-24")]
Rgb24,
}
});
assert!(word.contains("it names the UPSTREAM variant"), "{word}");
}
#[test]
fn the_wire_name_is_the_declarations_and_reaches_nothing_else() {
let model = accepted(&syn::parse_quote! {
#[ingraph(graphql(rename = "BodyJoint"))]
pub enum BodyJointName { Nose, LeftShoulder }
});
assert_eq!(model.wire_name.as_deref(), Some("BodyJoint"));
assert_eq!(model.name, "BodyJointName", "the Rust name does not move");
assert_eq!(
model.error().to_string(),
"BodyJointNameParseError",
"the refusal type is built from the RUST name, which the wire word never touched"
);
}
#[test]
fn the_wire_block_holds_a_name_beside_a_form() {
let both = accepted(&syn::parse_quote! {
#[ingraph(graphql(text, rename = "Codec"))]
pub enum VideoCodec { H264, Vp9 }
});
assert_eq!(both.wire_name.as_deref(), Some("Codec"));
assert_eq!(both.form(Namespace::Graphql), StorageForm::Text);
let neither = accepted(&syn::parse_quote! {
pub enum VideoCodec { H264, Vp9 }
});
assert_eq!(neither.wire_name, None);
}
#[test]
fn a_word_storing_mode_still_names_its_scalar() {
let open = accepted(&syn::parse_quote! {
#[ingraph(graphql(rename = "BodyJoint"))]
pub enum BodyJointName {
Nose,
#[ingraph(other)]
Other(::ingraph::Utf8Bytes),
}
});
assert_eq!(open.wire_name.as_deref(), Some("BodyJoint"));
let mirror = accepted(&syn::parse_quote! {
#[ingraph(remote = "upstream::Codec", graphql(rename = "Codec"))]
pub enum MirroredCodec { H264, Vp9 }
});
assert_eq!(mirror.wire_name.as_deref(), Some("Codec"));
let form = refusal(&syn::parse_quote! {
#[ingraph(remote = "upstream::Codec", graphql(text))]
pub enum MirroredCodec { H264, Vp9 }
});
assert!(form.contains("names a FORM for one face"), "{form}");
}
#[test]
fn refuses_a_wire_name_outside_graphqls_own_grammar() {
for spelling in ["", "Not A Name", "9Lives"] {
let refused = refusal(&syn::parse_quote! {
#[ingraph(graphql(rename = #spelling))]
pub enum Codec { H264 }
});
assert!(
refused.contains("is not a GraphQL name") || refused.contains("a word in a string literal"),
"{spelling:?}: {refused}"
);
}
}
#[test]
fn a_wire_name_may_be_a_rust_keyword() {
let model = accepted(&syn::parse_quote! {
#[ingraph(graphql(rename = "type"))]
pub enum Kind { Reel, Frame }
});
assert_eq!(model.wire_name.as_deref(), Some("type"));
}
#[test]
fn refuses_a_wire_name_declared_twice() {
let refused = refusal(&syn::parse_quote! {
#[ingraph(graphql(rename = "A", rename = "B"))]
pub enum Codec { H264 }
});
assert!(
refused.contains("`rename` is declared more than once in `graphql(…)`"),
"{refused}"
);
}
#[test]
fn refuses_a_rename_on_a_stored_face() {
let refused = refusal(&syn::parse_quote! {
#[ingraph(sqlite(rename = "codecs"))]
pub enum Codec { H264 }
});
assert!(
refused.contains("STORES this vocabulary and does not name it"),
"{refused}"
);
assert!(
refused.contains("`graphql(rename = \"…\")`"),
"and it names the face that does: {refused}"
);
}