Skip to content

Commit

Permalink
updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ranile committed Aug 18, 2023
1 parent 55683ce commit 07804c9
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 25 deletions.
10 changes: 9 additions & 1 deletion packages/yew-macro/tests/hook_macro/use_prepared_state-fail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,31 @@ 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())
}

#[function_component]
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())
Expand Down
52 changes: 38 additions & 14 deletions packages/yew-macro/tests/hook_macro/use_prepared_state-fail.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}

Expand All @@ -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())
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
| ^^^
4 changes: 2 additions & 2 deletions packages/yew/tests/use_prepared_state.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 07804c9

Please sign in to comment.