* [yew-devel] [PATCH yew-widget-toolkit 0/4] update macro tests
@ 2025-01-14 11:44 Shannon Sterz
2025-01-14 11:44 ` [yew-devel] [PATCH yew-widget-toolkit 1/4] macros: update compiler version in invalid_type test Shannon Sterz
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Shannon Sterz @ 2025-01-14 11:44 UTC (permalink / raw)
To: yew-devel
this adapts the macro tests to the changes in the macros crate so that
they work again. note that for the compile tests we eventually want to
use `ui_test` [1] to more flexibly handle things like updated compiler
versions in the compilation output. however, this is not packaged yet,
so just use the `TRYBUILD=overwrite` environment variable to generate
the output for the current compiler version. this only effects one test
(`invalid_type`) at the moment.
[1]: https://crates.io/crates/ui_test
Shannon Sterz (4):
macros: update compiler version in invalid_type test
macros: update no_clone test to adjust to new additional traits
macros: update wrong_comp test to adjust to new additional traits
macros: update dummy pwt implementations so that the doc tests succeed
pwt-macros/src/lib.rs | 49 +++++++++++++++++++-
pwt-macros/tests/builder/invalid_type.stderr | 2 +-
pwt-macros/tests/widget/no_clone.rs | 13 ++++++
pwt-macros/tests/widget/no_clone.stderr | 8 ++--
pwt-macros/tests/widget/wrong_comp.rs | 21 ++++++++-
pwt-macros/tests/widget/wrong_comp.stderr | 4 +-
6 files changed, 87 insertions(+), 10 deletions(-)
--
2.39.5
_______________________________________________
yew-devel mailing list
yew-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* [yew-devel] [PATCH yew-widget-toolkit 1/4] macros: update compiler version in invalid_type test
2025-01-14 11:44 [yew-devel] [PATCH yew-widget-toolkit 0/4] update macro tests Shannon Sterz
@ 2025-01-14 11:44 ` Shannon Sterz
2025-01-14 11:44 ` [yew-devel] [PATCH yew-widget-toolkit 2/4] macros: update no_clone test to adjust to new additional traits Shannon Sterz
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Shannon Sterz @ 2025-01-14 11:44 UTC (permalink / raw)
To: yew-devel
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
pwt-macros/tests/builder/invalid_type.stderr | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pwt-macros/tests/builder/invalid_type.stderr b/pwt-macros/tests/builder/invalid_type.stderr
index 1920c2bf..b3edd69e 100644
--- a/pwt-macros/tests/builder/invalid_type.stderr
+++ b/pwt-macros/tests/builder/invalid_type.stderr
@@ -16,4 +16,4 @@ help: the return type of this call is `{float}` due to the type of the argument
6 | | wrong_type: i32,
| |______________^
note: method defined here
- --> /usr/src/rustc-1.70.0/library/core/src/option.rs:971:18
+ --> /usr/src/rustc-1.84.0/library/core/src/option.rs:992:12
--
2.39.5
_______________________________________________
yew-devel mailing list
yew-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* [yew-devel] [PATCH yew-widget-toolkit 2/4] macros: update no_clone test to adjust to new additional traits
2025-01-14 11:44 [yew-devel] [PATCH yew-widget-toolkit 0/4] update macro tests Shannon Sterz
2025-01-14 11:44 ` [yew-devel] [PATCH yew-widget-toolkit 1/4] macros: update compiler version in invalid_type test Shannon Sterz
@ 2025-01-14 11:44 ` Shannon Sterz
2025-01-14 11:44 ` [yew-devel] [PATCH yew-widget-toolkit 3/4] macros: update wrong_comp " Shannon Sterz
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Shannon Sterz @ 2025-01-14 11:44 UTC (permalink / raw)
To: yew-devel
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
pwt-macros/tests/widget/no_clone.rs | 13 +++++++++++++
pwt-macros/tests/widget/no_clone.stderr | 8 ++++----
2 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/pwt-macros/tests/widget/no_clone.rs b/pwt-macros/tests/widget/no_clone.rs
index 72217833..d0fbcbe6 100644
--- a/pwt-macros/tests/widget/no_clone.rs
+++ b/pwt-macros/tests/widget/no_clone.rs
@@ -11,9 +11,21 @@ mod props {
}
pub trait CssPaddingBuilder {}
pub trait CssMarginBuilder {}
+ pub trait AsCssStylesMut {
+ fn as_css_styles_mut(&mut self) -> &mut CssStyles;
+ }
+
+ /// Holds the CSS styles to set on elements
+ #[derive(Clone, Default, Debug, PartialEq)]
+ pub struct CssStyles {}
+
+ pub trait WidgetStyleBuilder {}
+
pub trait WidgetBuilder: Sized {
fn as_std_props_mut(&mut self) -> &mut WidgetStdProps;
+ fn as_std_props(&self) -> &WidgetStdProps;
}
+
pub trait AsClassesMut {
fn as_classes_mut(&mut self) -> &mut Classes;
}
@@ -23,6 +35,7 @@ mod props {
pub struct WidgetStdProps {
pub key: Option<Key>,
pub class: Classes,
+ pub styles: CssStyles,
}
#[derive(PartialEq, Default, Clone)]
pub struct ListenersWrapper {}
diff --git a/pwt-macros/tests/widget/no_clone.stderr b/pwt-macros/tests/widget/no_clone.stderr
index 28b52008..9f6f296c 100644
--- a/pwt-macros/tests/widget/no_clone.stderr
+++ b/pwt-macros/tests/widget/no_clone.stderr
@@ -1,12 +1,12 @@
error[E0277]: the trait bound `Foo: Clone` is not satisfied
- --> tests/widget/no_clone.rs:34:1
+ --> tests/widget/no_clone.rs:47:1
|
-34 | #[widget(pwt=crate, comp=FooComp, @input, @element)]
+47 | #[widget(pwt=crate, comp=FooComp, @input, @element)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `Foo`
|
= note: this error originates in the attribute macro `widget` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider annotating `Foo` with `#[derive(Clone)]`
|
-34 + #[derive(Clone)]
-35 | #[widget(pwt=crate, comp=FooComp, @input, @element)]
+47 + #[derive(Clone)]
+48 | #[widget(pwt=crate, comp=FooComp, @input, @element)]
|
--
2.39.5
_______________________________________________
yew-devel mailing list
yew-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* [yew-devel] [PATCH yew-widget-toolkit 3/4] macros: update wrong_comp test to adjust to new additional traits
2025-01-14 11:44 [yew-devel] [PATCH yew-widget-toolkit 0/4] update macro tests Shannon Sterz
2025-01-14 11:44 ` [yew-devel] [PATCH yew-widget-toolkit 1/4] macros: update compiler version in invalid_type test Shannon Sterz
2025-01-14 11:44 ` [yew-devel] [PATCH yew-widget-toolkit 2/4] macros: update no_clone test to adjust to new additional traits Shannon Sterz
@ 2025-01-14 11:44 ` Shannon Sterz
2025-01-14 11:44 ` [yew-devel] [PATCH yew-widget-toolkit 4/4] macros: update dummy pwt implementations so that the doc tests succeed Shannon Sterz
2025-01-14 12:24 ` [yew-devel] applied: [PATCH yew-widget-toolkit 0/4] update macro tests Dietmar Maurer
4 siblings, 0 replies; 6+ messages in thread
From: Shannon Sterz @ 2025-01-14 11:44 UTC (permalink / raw)
To: yew-devel
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
pwt-macros/tests/widget/wrong_comp.rs | 21 ++++++++++++++++++++-
pwt-macros/tests/widget/wrong_comp.stderr | 4 ++--
2 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/pwt-macros/tests/widget/wrong_comp.rs b/pwt-macros/tests/widget/wrong_comp.rs
index 54781677..403c7d94 100644
--- a/pwt-macros/tests/widget/wrong_comp.rs
+++ b/pwt-macros/tests/widget/wrong_comp.rs
@@ -11,8 +11,27 @@ mod props {
}
pub trait CssPaddingBuilder {}
pub trait CssMarginBuilder {}
+ pub trait AsCssStylesMut {
+ fn as_css_styles_mut(&mut self) -> &mut CssStyles;
+ }
+
+ /// Holds the CSS styles to set on elements
+ #[derive(Clone, Default, Debug, PartialEq)]
+ pub struct CssStyles {}
+
+ pub trait WidgetStyleBuilder {}
+
pub trait WidgetBuilder: Sized {
fn as_std_props_mut(&mut self) -> &mut WidgetStdProps;
+ fn as_std_props(&self) -> &WidgetStdProps;
+
+ fn class(mut self, class: impl Into<Classes>) -> Self {
+ self.add_class(class);
+ self
+ }
+ fn add_class(&mut self, class: impl Into<Classes>) {
+ self.as_std_props_mut().class.push(class);
+ }
}
pub trait AsClassesMut {
fn as_classes_mut(&mut self) -> &mut Classes;
@@ -23,11 +42,11 @@ mod props {
pub struct WidgetStdProps {
pub key: Option<Key>,
pub class: Classes,
+ pub styles: CssStyles,
}
#[derive(PartialEq, Default, Clone)]
pub struct ListenersWrapper {}
}
-
use pwt_macros::widget;
use yew::prelude::*;
diff --git a/pwt-macros/tests/widget/wrong_comp.stderr b/pwt-macros/tests/widget/wrong_comp.stderr
index 4e7e1279..c33f5549 100644
--- a/pwt-macros/tests/widget/wrong_comp.stderr
+++ b/pwt-macros/tests/widget/wrong_comp.stderr
@@ -1,5 +1,5 @@
error[E0412]: cannot find type `Wrong` in this scope
- --> tests/widget/wrong_comp.rs:34:26
+ --> tests/widget/wrong_comp.rs:53:26
|
-34 | #[widget(pwt=crate, comp=Wrong, @input, @element)]
+53 | #[widget(pwt=crate, comp=Wrong, @input, @element)]
| ^^^^^ not found in this scope
--
2.39.5
_______________________________________________
yew-devel mailing list
yew-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* [yew-devel] [PATCH yew-widget-toolkit 4/4] macros: update dummy pwt implementations so that the doc tests succeed
2025-01-14 11:44 [yew-devel] [PATCH yew-widget-toolkit 0/4] update macro tests Shannon Sterz
` (2 preceding siblings ...)
2025-01-14 11:44 ` [yew-devel] [PATCH yew-widget-toolkit 3/4] macros: update wrong_comp " Shannon Sterz
@ 2025-01-14 11:44 ` Shannon Sterz
2025-01-14 12:24 ` [yew-devel] applied: [PATCH yew-widget-toolkit 0/4] update macro tests Dietmar Maurer
4 siblings, 0 replies; 6+ messages in thread
From: Shannon Sterz @ 2025-01-14 11:44 UTC (permalink / raw)
To: yew-devel
adds the updated trait definitions and adds a dummy `oncklick`
implementation so that the doc tests succeed again
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
pwt-macros/src/lib.rs | 49 +++++++++++++++++++++++++++++++++++++++++--
1 file changed, 47 insertions(+), 2 deletions(-)
diff --git a/pwt-macros/src/lib.rs b/pwt-macros/src/lib.rs
index 1b62d1d9..1e353a0d 100644
--- a/pwt-macros/src/lib.rs
+++ b/pwt-macros/src/lib.rs
@@ -60,11 +60,25 @@ use builder::*;
/// # #[derive(Clone, PartialEq, Default)]
/// # pub struct WidgetStdProps {
/// # pub class: yew::Classes,
+/// # pub key: Option<yew::virtual_dom::Key>,
+/// # pub styles: CssStyles,
+/// # }
+/// # pub trait FieldBuilder {
+/// # fn as_input_props(&self) -> &FieldStdProps;
+/// # fn as_input_props_mut(&mut self) -> &mut FieldStdProps;
/// # }
/// # #[derive(Clone, PartialEq, Default)]
/// # pub struct ListenersWrapper;
-/// # pub trait WidgetBuilder {
+/// # pub trait WidgetBuilder: Sized {
/// # fn as_std_props_mut(&mut self) -> &mut WidgetStdProps;
+/// # fn as_std_props(&self) -> &WidgetStdProps;
+/// # fn class(mut self, class: impl Into<yew::Classes>) -> Self {
+/// # self.add_class(class);
+/// # self
+/// # }
+/// # fn add_class(&mut self, class: impl Into<yew::Classes>) {
+/// # self.as_std_props_mut().class.push(class);
+/// # }
/// # }
/// # pub trait AsClassesMut {
/// # fn as_classes_mut(&mut self) -> &mut yew::Classes;
@@ -72,12 +86,22 @@ use builder::*;
/// # pub trait CssBorderBuilder {}
/// # pub trait CssMarginBuilder {}
/// # pub trait CssPaddingBuilder {}
+/// # pub trait AsCssStylesMut {
+/// # fn as_css_styles_mut(&mut self) -> &mut CssStyles;
+/// # }
+/// # #[derive(Clone, Default, Debug, PartialEq)]
+/// # pub struct CssStyles {}
/// # pub trait EventSubscriber: Sized {
/// # fn as_listeners_mut(&mut self) -> &mut ListenersWrapper;
+/// #
+/// # // dummy implementation so that the test case succeeds below
/// # fn onclick(mut self, _cb: impl yew::html::IntoEventCallback<yew::MouseEvent>) -> Self {
/// # self
/// # }
/// # }
+/// # pub trait WidgetStyleBuilder {}
+/// # #[derive(PartialEq, Default, Clone)]
+/// # pub struct FieldStdProps {}
/// # }
/// # }
/// use pwt_macros::widget;
@@ -121,11 +145,24 @@ use builder::*;
/// # pub struct WidgetStdProps {
/// # pub class: yew::Classes,
/// # pub key: Option<yew::virtual_dom::Key>,
+/// # pub styles: CssStyles,
+/// # }
+/// # pub trait FieldBuilder {
+/// # fn as_input_props(&self) -> &FieldStdProps;
+/// # fn as_input_props_mut(&mut self) -> &mut FieldStdProps;
/// # }
/// # #[derive(Clone, PartialEq, Default)]
/// # pub struct ListenersWrapper;
-/// # pub trait WidgetBuilder {
+/// # pub trait WidgetBuilder: Sized {
/// # fn as_std_props_mut(&mut self) -> &mut WidgetStdProps;
+/// # fn as_std_props(&self) -> &WidgetStdProps;
+/// # fn class(mut self, class: impl Into<yew::Classes>) -> Self {
+/// # self.add_class(class);
+/// # self
+/// # }
+/// # fn add_class(&mut self, class: impl Into<yew::Classes>) {
+/// # self.as_std_props_mut().class.push(class);
+/// # }
/// # }
/// # pub trait AsClassesMut {
/// # fn as_classes_mut(&mut self) -> &mut yew::Classes;
@@ -133,9 +170,17 @@ use builder::*;
/// # pub trait CssBorderBuilder {}
/// # pub trait CssMarginBuilder {}
/// # pub trait CssPaddingBuilder {}
+/// # pub trait AsCssStylesMut {
+/// # fn as_css_styles_mut(&mut self) -> &mut CssStyles;
+/// # }
+/// # #[derive(Clone, Default, Debug, PartialEq)]
+/// # pub struct CssStyles {}
/// # pub trait EventSubscriber: Sized {
/// # fn as_listeners_mut(&mut self) -> &mut ListenersWrapper;
/// # }
+/// # pub trait WidgetStyleBuilder {}
+/// # #[derive(PartialEq, Default, Clone)]
+/// # pub struct FieldStdProps {}
/// # }
/// # }
/// use pwt_macros::widget;
--
2.39.5
_______________________________________________
yew-devel mailing list
yew-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* [yew-devel] applied: [PATCH yew-widget-toolkit 0/4] update macro tests
2025-01-14 11:44 [yew-devel] [PATCH yew-widget-toolkit 0/4] update macro tests Shannon Sterz
` (3 preceding siblings ...)
2025-01-14 11:44 ` [yew-devel] [PATCH yew-widget-toolkit 4/4] macros: update dummy pwt implementations so that the doc tests succeed Shannon Sterz
@ 2025-01-14 12:24 ` Dietmar Maurer
4 siblings, 0 replies; 6+ messages in thread
From: Dietmar Maurer @ 2025-01-14 12:24 UTC (permalink / raw)
To: Yew framework devel list at Proxmox, Shannon Sterz
applied
_______________________________________________
yew-devel mailing list
yew-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-01-14 12:24 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-14 11:44 [yew-devel] [PATCH yew-widget-toolkit 0/4] update macro tests Shannon Sterz
2025-01-14 11:44 ` [yew-devel] [PATCH yew-widget-toolkit 1/4] macros: update compiler version in invalid_type test Shannon Sterz
2025-01-14 11:44 ` [yew-devel] [PATCH yew-widget-toolkit 2/4] macros: update no_clone test to adjust to new additional traits Shannon Sterz
2025-01-14 11:44 ` [yew-devel] [PATCH yew-widget-toolkit 3/4] macros: update wrong_comp " Shannon Sterz
2025-01-14 11:44 ` [yew-devel] [PATCH yew-widget-toolkit 4/4] macros: update dummy pwt implementations so that the doc tests succeed Shannon Sterz
2025-01-14 12:24 ` [yew-devel] applied: [PATCH yew-widget-toolkit 0/4] update macro tests Dietmar Maurer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox