Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
166 additions
and
6 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
packages/yew-macro/tests/hook_macro/use_prepared_state-fail.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use yew::prelude::*; | ||
use yew_macro::{use_prepared_state_with_closure, use_prepared_state_without_closure}; | ||
|
||
#[function_component] | ||
fn Comp() -> HtmlResult { | ||
use_prepared_state_with_closure!(123)?; | ||
|
||
use_prepared_state_with_closure!(|_| { todo!() }, 123)?; | ||
|
||
use_prepared_state_with_closure!(|_| -> u32 { todo!() })?; | ||
|
||
use_prepared_state_with_closure!(async |_| -> u32 { todo!() })?; | ||
|
||
Ok(Html::default()) | ||
} | ||
|
||
#[function_component] | ||
fn Comp2() -> HtmlResult { | ||
use_prepared_state_without_closure!(123)?; | ||
|
||
use_prepared_state_without_closure!(|_| { todo!() }, 123)?; | ||
|
||
use_prepared_state_without_closure!(|_| -> u32 { todo!() })?; | ||
|
||
use_prepared_state_without_closure!(async |_| -> u32 { todo!() })?; | ||
|
||
Ok(Html::default()) | ||
} | ||
|
||
fn main() {} |
55 changes: 55 additions & 0 deletions
55
packages/yew-macro/tests/hook_macro/use_prepared_state-fail.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
error: expected `|` | ||
--> tests/hook_macro/use_prepared_state-fail.rs:6:38 | ||
| | ||
6 | use_prepared_state_with_closure!(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_prepared_state-fail.rs:8:38 | ||
| | ||
8 | use_prepared_state_with_closure!(|_| { todo!() }, 123)?; | ||
| ^^^^^^^^^^^^^^^ | ||
|
||
error: expected `,` | ||
--> tests/hook_macro/use_prepared_state-fail.rs:10:5 | ||
| | ||
10 | use_prepared_state_with_closure!(|_| -> 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 `,` | ||
--> tests/hook_macro/use_prepared_state-fail.rs:12:5 | ||
| | ||
12 | 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 `|` | ||
--> tests/hook_macro/use_prepared_state-fail.rs:19:41 | ||
| | ||
19 | use_prepared_state_without_closure!(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_prepared_state-fail.rs:21:41 | ||
| | ||
21 | use_prepared_state_without_closure!(|_| { todo!() }, 123)?; | ||
| ^^^^^^^^^^^^^^^ | ||
|
||
error: expected `,` | ||
--> tests/hook_macro/use_prepared_state-fail.rs:23:5 | ||
| | ||
23 | 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 `,` | ||
--> tests/hook_macro/use_prepared_state-fail.rs:25:5 | ||
| | ||
25 | 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) |
26 changes: 26 additions & 0 deletions
26
packages/yew-macro/tests/hook_macro/use_transitive_state-fail.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use yew::prelude::*; | ||
use yew_macro::{use_transitive_state_with_closure, use_transitive_state_without_closure}; | ||
|
||
#[function_component] | ||
fn Comp() -> HtmlResult { | ||
use_transitive_state_with_closure!(123)?; | ||
|
||
use_transitive_state_with_closure!(|_| { todo!() }, 123)?; | ||
|
||
use_transitive_state_with_closure!(|_| -> u32 { todo!() })?; | ||
|
||
Ok(Html::default()) | ||
} | ||
|
||
#[function_component] | ||
fn Comp2() -> HtmlResult { | ||
use_transitive_state_without_closure!(123)?; | ||
|
||
use_transitive_state_without_closure!(|_| { todo!() }, 123)?; | ||
|
||
use_transitive_state_without_closure!(|_| -> u32 { todo!() })?; | ||
|
||
Ok(Html::default()) | ||
} | ||
|
||
fn main() {} |
39 changes: 39 additions & 0 deletions
39
packages/yew-macro/tests/hook_macro/use_transitive_state-fail.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
error: expected `|` | ||
--> tests/hook_macro/use_transitive_state-fail.rs:6:40 | ||
| | ||
6 | use_transitive_state_with_closure!(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:8:40 | ||
| | ||
8 | use_transitive_state_with_closure!(|_| { todo!() }, 123)?; | ||
| ^^^^^^^^^^^^^^^ | ||
|
||
error: expected `,` | ||
--> tests/hook_macro/use_transitive_state-fail.rs:10:5 | ||
| | ||
10 | 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 `|` | ||
--> tests/hook_macro/use_transitive_state-fail.rs:17:43 | ||
| | ||
17 | use_transitive_state_without_closure!(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:19:43 | ||
| | ||
19 | use_transitive_state_without_closure!(|_| { todo!() }, 123)?; | ||
| ^^^^^^^^^^^^^^^ | ||
|
||
error: expected `,` | ||
--> tests/hook_macro/use_transitive_state-fail.rs:21:5 | ||
| | ||
21 | 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#[allow(dead_code)] | ||
#[rustversion::attr(stable(1.56), test)] | ||
fn tests() { | ||
let t = trybuild::TestCases::new(); | ||
t.pass("tests/hook_macro/*-pass.rs"); | ||
t.compile_fail("tests/hook_macro/*-fail.rs"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters