use super::*;
use crate::{
BytesFilter, EnumFilter, ListFilter, Nullable, QuantifiedFilter, SetFilter, TextFilter,
};
fn same<A>(_: core::marker::PhantomData<A>, _: core::marker::PhantomData<A>) {}
struct Roll<T>(core::marker::PhantomData<T>);
struct Tag;
impl EnumFilterMarker for Tag {
type Filter = EnumFilter<Tag>;
}
impl DefaultMarker for Tag {
type Marker = EnumMarker<Tag>;
}
impl DefaultVecMarker for Tag {
type Marker = ListMarker<Vec<Tag>>;
}
impl BytesFilterMarker for Roll<Tag> {
type Filter = BytesFilter<Roll<Tag>>;
}
impl<T> State<Extracted<Inner>> for Roll<T> {
type Output = T;
}
impl<T> ListFilterMarker for Roll<T> {
type Filter<VF> = ListFilter<T, VF>;
}
impl<T> SetFilterMarker for Roll<T> {
type Filter<VF> = SetFilter<T, VF>;
}
impl<T> QuantifiedFilterMarker for Roll<T> {
type Filter<VF> = QuantifiedFilter<T, VF>;
}
#[test]
fn one_type_answers_once_per_position() {
same(
core::marker::PhantomData::<<BytesMarker<Roll<Tag>> as ToGraphqlFilter>::Filter>,
core::marker::PhantomData::<BytesFilter<Roll<Tag>>>,
);
same(
core::marker::PhantomData::<<ListMarker<Roll<Tag>> as ToGraphqlFilter>::Filter>,
core::marker::PhantomData::<ListFilter<Tag, EnumFilter<Tag>>>,
);
same(
core::marker::PhantomData::<<SetMarker<Roll<Tag>> as ToGraphqlFilter>::Filter>,
core::marker::PhantomData::<SetFilter<Tag, EnumFilter<Tag>>>,
);
same(
core::marker::PhantomData::<<QuantifiedMarker<Roll<Tag>> as ToGraphqlFilter>::Filter>,
core::marker::PhantomData::<QuantifiedFilter<Tag, EnumFilter<Tag>>>,
);
}
#[test]
fn one_type_answers_two_value_families() {
struct Label;
impl StringFilterMarker for Label {
type Filter = TextFilter<Label>;
}
impl BytesFilterMarker for Label {
type Filter = BytesFilter<Label>;
}
same(
core::marker::PhantomData::<<StringMarker<Label> as ToGraphqlFilter>::Filter>,
core::marker::PhantomData::<TextFilter<Label>>,
);
same(
core::marker::PhantomData::<<BytesMarker<Label> as ToGraphqlFilter>::Filter>,
core::marker::PhantomData::<BytesFilter<Label>>,
);
}
#[test]
fn the_frameworks_vec_rows_cover_an_unregistered_element() {
same(
core::marker::PhantomData::<<ListMarker<Vec<Tag>> as ToGraphqlFilter>::Filter>,
core::marker::PhantomData::<ListFilter<Tag>>,
);
same(
core::marker::PhantomData::<<SetMarker<Vec<Tag>> as ToGraphqlFilter>::Filter>,
core::marker::PhantomData::<SetFilter<Tag>>,
);
same(
core::marker::PhantomData::<<QuantifiedMarker<Vec<Tag>> as ToGraphqlFilter>::Filter>,
core::marker::PhantomData::<QuantifiedFilter<Tag>>,
);
}
#[test]
fn a_nullable_marker_wraps_the_interpretation_below_it() {
struct Reel;
impl StringFilterMarker for Reel {
type Filter = TextFilter<Reel>;
}
same(
core::marker::PhantomData::<
<NullableMarker<Option<Reel>, StringMarker<Reel>> as ToGraphqlFilter>::Filter,
>,
core::marker::PhantomData::<Nullable<TextFilter<Reel>>>,
);
same(
core::marker::PhantomData::<
<NullableMarker<Option<Roll<Tag>>, ListMarker<Roll<Tag>>> as ToGraphqlFilter>::Filter,
>,
core::marker::PhantomData::<Nullable<ListFilter<Tag, EnumFilter<Tag>>>>,
);
same(
core::marker::PhantomData::<
<NullableMarker<Option<Roll<Tag>>, SetMarker<Roll<Tag>>> as ToGraphqlFilter>::Filter,
>,
core::marker::PhantomData::<Nullable<SetFilter<Tag, EnumFilter<Tag>>>>,
);
}
#[test]
fn an_option_infers_the_null_test_over_the_inner_marker() {
struct Codec;
impl EnumFilterMarker for Codec {
type Filter = EnumFilter<Codec>;
}
impl DefaultMarker for Codec {
type Marker = EnumMarker<Codec>;
}
same(
core::marker::PhantomData::<<<Codec as DefaultMarker>::Marker as ToGraphqlFilter>::Filter>,
core::marker::PhantomData::<EnumFilter<Codec>>,
);
same(
core::marker::PhantomData::<
<<Option<Codec> as DefaultMarker>::Marker as ToGraphqlFilter>::Filter,
>,
core::marker::PhantomData::<Nullable<EnumFilter<Codec>>>,
);
}
#[test]
fn a_vec_takes_its_default_from_its_element() {
struct Note;
struct Label;
impl EnumFilterMarker for Note {
type Filter = EnumFilter<Note>;
}
impl DefaultMarker for Note {
type Marker = EnumMarker<Note>;
}
impl EnumFilterMarker for Label {
type Filter = EnumFilter<Label>;
}
impl DefaultMarker for Label {
type Marker = EnumMarker<Label>;
}
impl DefaultVecMarker for Note {
type Marker = ListMarker<Vec<Note>>;
}
impl DefaultVecMarker for Label {
type Marker = SetMarker<Vec<Label>>;
}
same(
core::marker::PhantomData::<<<Vec<Note> as DefaultMarker>::Marker as ToGraphqlFilter>::Filter>,
core::marker::PhantomData::<ListFilter<Note>>,
);
same(
core::marker::PhantomData::<<<Vec<Label> as DefaultMarker>::Marker as ToGraphqlFilter>::Filter>,
core::marker::PhantomData::<SetFilter<Label>>,
);
same(
core::marker::PhantomData::<
<<Option<Vec<Label>> as DefaultMarker>::Marker as ToGraphqlFilter>::Filter,
>,
core::marker::PhantomData::<SetFilter<Label>>,
);
}
#[test]
fn a_vec_takes_the_quantified_reading_from_its_element() {
use core::marker::PhantomData as P;
struct Sighting(
#[expect(
dead_code,
reason = "the field IS the fixture: a float is what leaves this element with no honest \
literal form, and a `Cell` is what leaves it neither `Send` nor `Sync`. Both are \
properties the projection below has to resolve WITHOUT, so a fixture that read the \
value would be asserting less than this one does"
)]
core::cell::Cell<f32>,
);
struct SightingFilter;
impl ScalarFilterMarker for Sighting {
type Filter = SightingFilter;
}
impl DefaultMarker for Sighting {
type Marker = ScalarMarker<Sighting>;
}
impl DefaultVecMarker for Sighting {
type Marker = QuantifiedMarker<Vec<Sighting>>;
}
same(
P::<<<Vec<Sighting> as DefaultMarker>::Marker as ToGraphqlFilter>::Filter>,
P::<QuantifiedFilter<Sighting, SightingFilter>>,
);
same(
P::<<<Option<Vec<Sighting>> as DefaultMarker>::Marker as ToGraphqlFilter>::Filter>,
P::<QuantifiedFilter<Sighting, SightingFilter>>,
);
}
#[test]
fn an_inner_marker_overrides_the_elements_default_reading() {
use core::marker::PhantomData as P;
use crate::{ScalarFilter, ScalarMarker};
same(
P::<<ListMarker<Vec<Vec<u8>>> as ToGraphqlFilter>::Filter>,
P::<ListFilter<Vec<u8>, BytesFilter<Vec<u8>>>>,
);
same(
P::<<ListMarker<Vec<Vec<u8>>, ListMarker<Vec<u8>>> as ToGraphqlFilter>::Filter>,
P::<ListFilter<Vec<u8>, ListFilter<u8, ScalarFilter<u8>>>>,
);
same(
P::<<ListMarker<Vec<u8>, ScalarMarker<u8>> as ToGraphqlFilter>::Filter>,
P::<<ListMarker<Vec<u8>> as ToGraphqlFilter>::Filter>,
);
}
#[test]
fn a_marker_names_the_reading_an_option_of_it_takes() {
use core::marker::PhantomData as P;
same(
P::<<EnumMarker<Tag> as Marker>::UnderOption>,
P::<NullableMarker<Option<Tag>, EnumMarker<Tag>>>,
);
same(
P::<<ListMarker<Roll<Tag>> as Marker>::UnderOption>,
P::<OptionalMarker<Option<Roll<Tag>>, ListMarker<Roll<Tag>>>>,
);
same(
P::<<SetMarker<Roll<Tag>> as Marker>::UnderOption>,
P::<OptionalMarker<Option<Roll<Tag>>, SetMarker<Roll<Tag>>>>,
);
same(
P::<<QuantifiedMarker<Roll<Tag>> as Marker>::UnderOption>,
P::<OptionalMarker<Option<Roll<Tag>>, QuantifiedMarker<Roll<Tag>>>>,
);
same(
P::<<NullableMarker<Option<Tag>, EnumMarker<Tag>> as Marker>::UnderOption>,
P::<NullableMarker<Option<Option<Tag>>, NullableMarker<Option<Tag>, EnumMarker<Tag>>>>,
);
same(
P::<<OptionalMarker<Option<Roll<Tag>>, ListMarker<Roll<Tag>>> as Marker>::UnderOption>,
P::<
OptionalMarker<
Option<Option<Roll<Tag>>>,
OptionalMarker<Option<Roll<Tag>>, ListMarker<Roll<Tag>>>,
>,
>,
);
}
#[test]
fn an_optional_reading_resolves_to_the_inner_markers_filter() {
use core::marker::PhantomData as P;
same(
P::<<OptionalMarker<Option<Roll<Tag>>, ListMarker<Roll<Tag>>> as ToGraphqlFilter>::Filter>,
P::<ListFilter<Tag, EnumFilter<Tag>>>,
);
same(
P::<<NullableMarker<Option<Roll<Tag>>, ListMarker<Roll<Tag>>> as ToGraphqlFilter>::Filter>,
P::<Nullable<ListFilter<Tag, EnumFilter<Tag>>>>,
);
same(
P::<<OptionalMarker<Option<Vec<Tag>>> as ToGraphqlFilter>::Filter>,
P::<ListFilter<Tag, EnumFilter<Tag>>>,
);
}
#[test]
fn the_omitted_parameter_is_the_elements_own_reading() {
use core::marker::PhantomData as P;
same(
P::<<ListMarker<Vec<Tag>> as ToGraphqlFilter>::Filter>,
P::<ListFilter<Tag, EnumFilter<Tag>>>,
);
same(
P::<<SetMarker<Vec<Tag>> as ToGraphqlFilter>::Filter>,
P::<SetFilter<Tag, EnumFilter<Tag>>>,
);
same(
P::<<QuantifiedMarker<Vec<Tag>> as ToGraphqlFilter>::Filter>,
P::<QuantifiedFilter<Tag, EnumFilter<Tag>>>,
);
same(
P::<<NullableMarker<Option<Tag>> as ToGraphqlFilter>::Filter>,
P::<Nullable<EnumFilter<Tag>>>,
);
}