From 07804c9e010a736d74c70702e242344d5d969a8f Mon Sep 17 00:00:00 2001 From: Muhammad Hamza Date: Sat, 19 Aug 2023 00:56:00 +0500 Subject: [PATCH] updated tests --- .../hook_macro/use_prepared_state-fail.rs | 10 +++- .../hook_macro/use_prepared_state-fail.stderr | 52 ++++++++++++++----- .../hook_macro/use_transitive_state-fail.rs | 8 +++ .../use_transitive_state-fail.stderr | 40 +++++++++++--- packages/yew/tests/use_prepared_state.rs | 4 +- 5 files changed, 89 insertions(+), 25 deletions(-) diff --git a/packages/yew-macro/tests/hook_macro/use_prepared_state-fail.rs b/packages/yew-macro/tests/hook_macro/use_prepared_state-fail.rs index e12ee98fe64..b7181f04d23 100644 --- a/packages/yew-macro/tests/hook_macro/use_prepared_state-fail.rs +++ b/packages/yew-macro/tests/hook_macro/use_prepared_state-fail.rs @@ -5,12 +5,16 @@ use yew_macro::{use_prepared_state_with_closure, use_prepared_state_without_clos fn Comp() -> HtmlResult { use_prepared_state_with_closure!(123)?; - use_prepared_state_with_closure!(|_| { todo!() }, 123)?; + use_prepared_state_with_closure!(123, |_| { todo!() })?; use_prepared_state_with_closure!(|_| -> u32 { todo!() })?; + use_prepared_state_with_closure!(|_| -> u32 { todo!() }, 123)?; + use_prepared_state_with_closure!(async |_| -> u32 { todo!() })?; + use_prepared_state_with_closure!(|_| { todo!() }, 123)?; + Ok(Html::default()) } @@ -18,10 +22,14 @@ fn Comp() -> HtmlResult { fn Comp2() -> HtmlResult { use_prepared_state_without_closure!(123)?; + use_prepared_state_without_closure!(123, |_| { todo!() })?; + use_prepared_state_without_closure!(|_| { todo!() }, 123)?; use_prepared_state_without_closure!(|_| -> u32 { todo!() })?; + use_prepared_state_without_closure!(|_| -> u32 { todo!() }, 123)?; + use_prepared_state_without_closure!(async |_| -> u32 { todo!() })?; Ok(Html::default()) diff --git a/packages/yew-macro/tests/hook_macro/use_prepared_state-fail.stderr b/packages/yew-macro/tests/hook_macro/use_prepared_state-fail.stderr index 9adf7f294a3..775071c00d3 100644 --- a/packages/yew-macro/tests/hook_macro/use_prepared_state-fail.stderr +++ b/packages/yew-macro/tests/hook_macro/use_prepared_state-fail.stderr @@ -6,11 +6,11 @@ error: this hook takes 2 arguments but 1 argument was supplied | = note: this error originates in the macro `use_prepared_state_with_closure` (in Nightly builds, run with -Z macro-backtrace for more info) -error: expected closure - --> tests/hook_macro/use_prepared_state-fail.rs:8:55 +error: You must specify a return type for this closure. This is used when the closure is omitted from the client side rendering bundle. + --> tests/hook_macro/use_prepared_state-fail.rs:8:43 | -8 | use_prepared_state_with_closure!(|_| { todo!() }, 123)?; - | ^^^ +8 | use_prepared_state_with_closure!(123, |_| { todo!() })?; + | ^^^^^^^^^^^^^^^ error: this hook takes 2 arguments but 1 argument was supplied --> tests/hook_macro/use_prepared_state-fail.rs:10:5 @@ -20,40 +20,64 @@ error: this hook takes 2 arguments but 1 argument was supplied | = note: this error originates in the macro `use_prepared_state_with_closure` (in Nightly builds, run with -Z macro-backtrace for more info) +error: expected closure + --> tests/hook_macro/use_prepared_state-fail.rs:12:62 + | +12 | use_prepared_state_with_closure!(|_| -> u32 { todo!() }, 123)?; + | ^^^ + error: this hook takes 2 arguments but 1 argument was supplied - --> tests/hook_macro/use_prepared_state-fail.rs:12:5 + --> tests/hook_macro/use_prepared_state-fail.rs:14:5 | -12 | use_prepared_state_with_closure!(async |_| -> u32 { todo!() })?; +14 | use_prepared_state_with_closure!(async |_| -> u32 { todo!() })?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this error originates in the macro `use_prepared_state_with_closure` (in Nightly builds, run with -Z macro-backtrace for more info) +error: expected closure + --> tests/hook_macro/use_prepared_state-fail.rs:16:55 + | +16 | use_prepared_state_with_closure!(|_| { todo!() }, 123)?; + | ^^^ + error: this hook takes 2 arguments but 1 argument was supplied - --> tests/hook_macro/use_prepared_state-fail.rs:19:5 + --> tests/hook_macro/use_prepared_state-fail.rs:23:5 | -19 | use_prepared_state_without_closure!(123)?; +23 | use_prepared_state_without_closure!(123)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this error originates in the macro `use_prepared_state_without_closure` (in Nightly builds, run with -Z macro-backtrace for more info) +error: You must specify a return type for this closure. This is used when the closure is omitted from the client side rendering bundle. + --> tests/hook_macro/use_prepared_state-fail.rs:25:46 + | +25 | use_prepared_state_without_closure!(123, |_| { todo!() })?; + | ^^^^^^^^^^^^^^^ + error: expected closure - --> tests/hook_macro/use_prepared_state-fail.rs:21:58 + --> tests/hook_macro/use_prepared_state-fail.rs:27:58 | -21 | use_prepared_state_without_closure!(|_| { todo!() }, 123)?; +27 | use_prepared_state_without_closure!(|_| { todo!() }, 123)?; | ^^^ error: this hook takes 2 arguments but 1 argument was supplied - --> tests/hook_macro/use_prepared_state-fail.rs:23:5 + --> tests/hook_macro/use_prepared_state-fail.rs:29:5 | -23 | use_prepared_state_without_closure!(|_| -> u32 { todo!() })?; +29 | use_prepared_state_without_closure!(|_| -> u32 { todo!() })?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this error originates in the macro `use_prepared_state_without_closure` (in Nightly builds, run with -Z macro-backtrace for more info) +error: expected closure + --> tests/hook_macro/use_prepared_state-fail.rs:31:65 + | +31 | use_prepared_state_without_closure!(|_| -> u32 { todo!() }, 123)?; + | ^^^ + error: this hook takes 2 arguments but 1 argument was supplied - --> tests/hook_macro/use_prepared_state-fail.rs:25:5 + --> tests/hook_macro/use_prepared_state-fail.rs:33:5 | -25 | use_prepared_state_without_closure!(async |_| -> u32 { todo!() })?; +33 | use_prepared_state_without_closure!(async |_| -> u32 { todo!() })?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this error originates in the macro `use_prepared_state_without_closure` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/packages/yew-macro/tests/hook_macro/use_transitive_state-fail.rs b/packages/yew-macro/tests/hook_macro/use_transitive_state-fail.rs index 113b0404ed3..42d6e42a85f 100644 --- a/packages/yew-macro/tests/hook_macro/use_transitive_state-fail.rs +++ b/packages/yew-macro/tests/hook_macro/use_transitive_state-fail.rs @@ -7,8 +7,12 @@ fn Comp() -> HtmlResult { use_transitive_state_with_closure!(|_| { todo!() }, 123)?; + use_transitive_state_with_closure!(123, |_| { todo!() })?; + use_transitive_state_with_closure!(|_| -> u32 { todo!() })?; + use_transitive_state_with_closure!(|_| -> u32 { todo!() }, 123)?; + Ok(Html::default()) } @@ -18,8 +22,12 @@ fn Comp2() -> HtmlResult { use_transitive_state_without_closure!(|_| { todo!() }, 123)?; + use_transitive_state_without_closure!(123, |_| { todo!() })?; + use_transitive_state_without_closure!(|_| -> u32 { todo!() })?; + use_transitive_state_without_closure!(|_| -> u32 { todo!() }, 123)?; + Ok(Html::default()) } diff --git a/packages/yew-macro/tests/hook_macro/use_transitive_state-fail.stderr b/packages/yew-macro/tests/hook_macro/use_transitive_state-fail.stderr index 8aa99b72603..b8293a39298 100644 --- a/packages/yew-macro/tests/hook_macro/use_transitive_state-fail.stderr +++ b/packages/yew-macro/tests/hook_macro/use_transitive_state-fail.stderr @@ -12,32 +12,56 @@ error: expected closure 8 | use_transitive_state_with_closure!(|_| { todo!() }, 123)?; | ^^^ +error: You must specify a return type for this closure. This is used when the closure is omitted from the client side rendering bundle. + --> tests/hook_macro/use_transitive_state-fail.rs:10:45 + | +10 | use_transitive_state_with_closure!(123, |_| { todo!() })?; + | ^^^^^^^^^^^^^^^ + error: this hook takes 2 arguments but 1 argument was supplied - --> tests/hook_macro/use_transitive_state-fail.rs:10:5 + --> tests/hook_macro/use_transitive_state-fail.rs:12:5 | -10 | use_transitive_state_with_closure!(|_| -> u32 { todo!() })?; +12 | use_transitive_state_with_closure!(|_| -> u32 { todo!() })?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this error originates in the macro `use_transitive_state_with_closure` (in Nightly builds, run with -Z macro-backtrace for more info) +error: expected closure + --> tests/hook_macro/use_transitive_state-fail.rs:14:64 + | +14 | use_transitive_state_with_closure!(|_| -> u32 { todo!() }, 123)?; + | ^^^ + error: this hook takes 2 arguments but 1 argument was supplied - --> tests/hook_macro/use_transitive_state-fail.rs:17:5 + --> tests/hook_macro/use_transitive_state-fail.rs:21:5 | -17 | use_transitive_state_without_closure!(123)?; +21 | use_transitive_state_without_closure!(123)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this error originates in the macro `use_transitive_state_without_closure` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected closure - --> tests/hook_macro/use_transitive_state-fail.rs:19:60 + --> tests/hook_macro/use_transitive_state-fail.rs:23:60 | -19 | use_transitive_state_without_closure!(|_| { todo!() }, 123)?; +23 | use_transitive_state_without_closure!(|_| { todo!() }, 123)?; | ^^^ +error: You must specify a return type for this closure. This is used when the closure is omitted from the client side rendering bundle. + --> tests/hook_macro/use_transitive_state-fail.rs:25:48 + | +25 | use_transitive_state_without_closure!(123, |_| { todo!() })?; + | ^^^^^^^^^^^^^^^ + error: this hook takes 2 arguments but 1 argument was supplied - --> tests/hook_macro/use_transitive_state-fail.rs:21:5 + --> tests/hook_macro/use_transitive_state-fail.rs:27:5 | -21 | use_transitive_state_without_closure!(|_| -> u32 { todo!() })?; +27 | use_transitive_state_without_closure!(|_| -> u32 { todo!() })?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this error originates in the macro `use_transitive_state_without_closure` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: expected closure + --> tests/hook_macro/use_transitive_state-fail.rs:29:67 + | +29 | use_transitive_state_without_closure!(|_| -> u32 { todo!() }, 123)?; + | ^^^ diff --git a/packages/yew/tests/use_prepared_state.rs b/packages/yew/tests/use_prepared_state.rs index 7545c675bb5..28644d026be 100644 --- a/packages/yew/tests/use_prepared_state.rs +++ b/packages/yew/tests/use_prepared_state.rs @@ -1,5 +1,5 @@ -// #![cfg(target_arch = "wasm32")] -// #![cfg(feature = "hydration")] +#![cfg(target_arch = "wasm32")] +#![cfg(feature = "hydration")] #![cfg_attr(nightly_yew, feature(async_closure))] use std::time::Duration;