diff --git a/packages/iocraft-macros/tests/with_layout_style_props.rs b/packages/iocraft-macros/tests/with_layout_style_props.rs index 169e36e..d24105d 100644 --- a/packages/iocraft-macros/tests/with_layout_style_props.rs +++ b/packages/iocraft-macros/tests/with_layout_style_props.rs @@ -19,6 +19,12 @@ struct MyPropsWithTypeGeneric { foo: Option, } +#[with_layout_style_props] +#[derive(Default, Props)] +struct MyPropsWithConstParam { + foo: Option<[u8; N]>, +} + #[test] fn layout_style_props() { let props: MyProps = Default::default(); @@ -32,4 +38,8 @@ fn layout_style_props() { let props: MyPropsWithTypeGeneric = Default::default(); assert_eq!(props.foo, None); assert_eq!(props.display, Display::DEFAULT); + + let props: MyPropsWithConstParam<1> = Default::default(); + assert_eq!(props.foo, None); + assert_eq!(props.display, Display::DEFAULT); } diff --git a/packages/iocraft/src/hooks/use_output.rs b/packages/iocraft/src/hooks/use_output.rs index 8fe7681..bb1d826 100644 --- a/packages/iocraft/src/hooks/use_output.rs +++ b/packages/iocraft/src/hooks/use_output.rs @@ -139,28 +139,49 @@ impl UseOutputImpl { #[cfg(test)] mod tests { use super::*; + use crate::prelude::*; use futures::task::noop_waker; + use macro_rules_attribute::apply; + use smol_macros::test; #[test] fn test_use_output_polling() { let mut use_output = UseOutputImpl::default(); assert_eq!( - Pin::new(&mut use_output).poll_change(&mut Context::from_waker(&noop_waker())), + Pin::new(&mut use_output) + .poll_change(&mut std::task::Context::from_waker(&noop_waker())), Poll::Pending ); let stdout = use_output.use_stdout(); stdout.println("Hello, world!"); assert_eq!( - Pin::new(&mut use_output).poll_change(&mut Context::from_waker(&noop_waker())), + Pin::new(&mut use_output) + .poll_change(&mut std::task::Context::from_waker(&noop_waker())), Poll::Ready(()) ); let stderr = use_output.use_stderr(); stderr.println("Hello, error!"); assert_eq!( - Pin::new(&mut use_output).poll_change(&mut Context::from_waker(&noop_waker())), + Pin::new(&mut use_output) + .poll_change(&mut std::task::Context::from_waker(&noop_waker())), Poll::Ready(()) ); } + + #[component] + fn MyComponent(mut hooks: Hooks) -> impl Into> { + let mut system = hooks.use_context_mut::(); + let (stdout, stderr) = hooks.use_output(); + stdout.println("Hello, world!"); + stderr.println("Hello, error!"); + system.exit(); + element!(Box) + } + + #[apply(test!)] + async fn test_use_output() { + element!(MyComponent).render_loop().await.unwrap(); + } }