collect tests
Some checks are pending
/ build (push) Waiting to run

This commit is contained in:
🪞👃🪞 2025-05-09 23:00:36 +03:00
parent 4a385b40ff
commit cb8fd26922
8 changed files with 234 additions and 257 deletions

View file

@ -5,7 +5,7 @@ pub(crate) struct ViewDef(pub(crate) ViewMeta, pub(crate) ViewImpl);
#[derive(Debug, Clone)]
pub(crate) struct ViewMeta {
output: Ident,
pub(crate) output: Ident,
}
#[derive(Debug, Clone)]
@ -114,123 +114,3 @@ impl ToTokens for ViewArm {
out.append(Punct::new(',', Alone));
}
}
//impl ToTokens for ViewSym {
//fn to_tokens (&self, out: &mut TokenStream2) {
//out.append(Punct::new(':', Joint));
//out.append(Punct::new(':', Alone));
//out.append(Ident::new("tengri", Span::call_site()));
//out.append(Punct::new(':', Joint));
//out.append(Punct::new(':', Alone));
//out.append(Ident::new("dsl", Span::call_site()));
//out.append(Punct::new(':', Joint));
//out.append(Punct::new(':', Alone));
//out.append(Ident::new("Value", Span::call_site()));
//out.append(Punct::new(':', Joint));
//out.append(Punct::new(':', Alone));
//out.append(Ident::new("Sym", Span::call_site()));
//out.append(Group::new(Delimiter::Parenthesis, {
//let mut out = TokenStream2::new();
//out.append(self.symbol.clone());
//out
//}));
//out.append(Punct::new('=', Joint));
//out.append(Punct::new('>', Alone));
//out.append(Ident::new("Some", Span::call_site()));
//out.append(Group::new(Delimiter::Parenthesis, {
//let mut out = TokenStream2::new();
//out.append(Ident::new("self", Span::call_site()));
//out.append(Punct::new('.', Alone));
//out.append(self.name.clone());
//out.append(Group::new(Delimiter::Parenthesis, TokenStream2::new()));
//out.append(Punct::new('.', Alone));
//out.append(Ident::new("boxed", Span::call_site()));
//out.append(Group::new(Delimiter::Parenthesis, TokenStream2::new()));
//out
//}));
//out.append(Punct::new(',', Alone));
//}
//}
//impl std::cmp::PartialEq for ViewItem {
//fn eq (&self, other: &Self) -> bool {
//self.item == other.item && (format!("{:?}", self.expose) == format!("{:?}", other.expose))
//}
//}
//impl std::cmp::PartialEq for ViewSym {
//fn eq (&self, other: &Self) -> bool {
//self.name == other.name && (format!("{}", self.symbol) == format!("{}", other.symbol))
//}
//}
#[cfg(test)] #[test] fn test_view_meta () {
let x: ViewMeta = pq! { SomeOutput };
let output: Ident = pq! { SomeOutput };
assert_eq!(x.output, output);
}
#[cfg(test)] #[test] fn test_view_impl () {
// TODO
let x: ViewImpl = pq! {
impl Foo {
/// docstring1
#[tengri::view(":view1")] #[bar] fn a_view () {}
#[baz]
/// docstring2
#[baz] fn is_not_view () {}
}
};
let expected_target: Ident = pq! { Foo };
//assert_eq!(x.target, expected_target);
//assert_eq!(x.items.len(), 2);
//assert_eq!(x.items[0].item, pq! {
///// docstring1
//#[bar] fn a_view () {}
//});
//assert_eq!(x.items[1].item, pq! {
//#[baz]
///// docstring2
//#[baz] fn is_not_view () {}
//});
//assert_eq!(x.syms, vec![
//ViewArm( { symbol: pq! { ":view1" }, name: pq! { a_view }, },
//]);
}
#[cfg(test)] #[test] fn test_view_definition () {
// FIXME
//let parsed: ViewDefinition = pq! {
//#[tengri_proc::view(SomeOutput)]
//impl SomeView {
//#[tengri::view(":view-1")]
//fn view_1 (&self) -> impl Content<SomeOutput> + use<'_> {
//"view-1"
//}
//}
//};
//let written = quote! { #parsed };
//assert_eq!(format!("{written}"), format!("{}", quote! {
//impl SomeView {
//fn view_1 (&self) -> impl Content<SomeOutput> + use<'_> {
//"view-1"
//}
//}
///// Generated by [tengri_proc].
//impl ::tengri::output::Content<SomeOutput> for SomeView {
//fn content (&self) -> impl Render<SomeOutput> {
//self.size.of(::tengri::output::View(self, self.config.view))
//}
//}
///// Generated by [tengri_proc].
//impl<'a> ::tengri::dsl::ViewContext<'a, SomeOutput> for SomeView {
//fn get_content_sym (&'a self, value: &Value<'a>) -> Option<RenderBox<'a, SomeOutput>> {
//match value {
//::tengri::dsl::Value::Sym(":view-1") => self.view_1().boxed(),
//_ => panic!("expected Sym(content), got: {value:?}")
//}
//}
//}
//}));
}