Jelajahi Sumber

restore core tests

Evan Almloff 1 tahun lalu
induk
melakukan
ad01a45f3b

+ 8 - 0
packages/core/src/diff/component.rs

@@ -65,10 +65,18 @@ impl VNode {
         dom: &mut VirtualDom,
         to: &mut impl WriteMutations,
     ) {
+        println!(
+            "diffing vcomponent: {new:#?} vs {old:#?}",
+            new = new,
+            old = old
+        );
+
         // Replace components that have different render fns
         if old.render_fn != new.render_fn {
+            println!("render fns are different, replacing");
             return self.replace_vcomponent(mount, idx, new, parent, dom, to);
         }
+        println!("render fns are the same, continuing");
 
         // copy out the box for both
         let old_scope = &mut dom.scopes[scope_id.0];

+ 1 - 1
packages/core/tests/context_api.rs

@@ -14,7 +14,7 @@ fn state_shares() {
     }
 
     fn child_2() -> Element {
-        let value = consume_context::<i32>().unwrap();
+        let value = consume_context::<i32>();
         rsx!("Value is {value}")
     }
 

+ 1 - 1
packages/core/tests/diff_component.rs

@@ -12,7 +12,7 @@ fn component_swap() {
 
         render_phase += 1;
 
-        match *render_phase() {
+        match render_phase() {
             0 => rsx! {
                 nav_bar {}
                 dash_board {}

+ 1 - 1
packages/core/tests/lifecycle.rs

@@ -45,7 +45,7 @@ fn events_generate() {
     fn app() -> Element {
         let mut count = use_signal(|| 0);
 
-        match *count() {
+        match count() {
             0 => rsx! {
                 div { onclick: move |_| count += 1,
                     div { "nested" }

+ 1 - 1
packages/core/tests/miri_full_app.rs

@@ -38,7 +38,7 @@ fn app() -> Element {
             }
             button { onclick: move |_| idx -= 1, "-" }
             ul {
-                {(0..*idx()).map(|i| rsx! {
+                {(0..idx()).map(|i| rsx! {
                     ChildExample { i: i, onhover: onhover }
                 })}
             }

+ 2 - 2
packages/core/tests/miri_simple.rs

@@ -42,7 +42,7 @@ fn contexts_drop() {
     }
 
     fn ChildComp() -> Element {
-        let el = consume_context::<String>().unwrap();
+        let el = consume_context::<String>();
 
         rsx! { div { "hello {el}" } }
     }
@@ -77,7 +77,7 @@ fn root_props_drop() {
     struct RootProps(String);
 
     let mut dom = VirtualDom::new_with_props(
-        |cx| rsx!( div { "{cx.0}" } ),
+        |cx: RootProps| rsx!( div { "{cx.0}" } ),
         RootProps("asdasd".to_string()),
     );
 

+ 3 - 3
packages/core/tests/miri_stress.rs

@@ -144,8 +144,8 @@ fn supports_async() {
     use tokio::time::sleep;
 
     fn app() -> Element {
-        let colors = use_signal(|| vec!["green", "blue", "red"]);
-        let padding = use_signal(|| 10);
+        let mut colors = use_signal(|| vec!["green", "blue", "red"]);
+        let mut padding = use_signal(|| 10);
 
         use_hook(|| {
             spawn(async move {
@@ -171,7 +171,7 @@ fn supports_async() {
             })
         });
 
-        let colors = colors();
+        let colors = colors.read();
         let big = colors[0];
         let mid = colors[1];
         let small = colors[2];

+ 1 - 1
packages/core/tests/suspense.rs

@@ -31,7 +31,7 @@ fn app() -> Element {
 fn suspended_child() -> Element {
     let mut val = use_signal(|| 0);
 
-    if *val() < 3 {
+    if val() < 3 {
         spawn(async move {
             val += 1;
         });

+ 1 - 1
packages/rsx/src/lib.rs

@@ -201,7 +201,7 @@ impl<'a> ToTokens for TemplateRenderer<'a> {
         };
 
         let key_tokens = match key {
-            Some(tok) => quote! { Some( #tok ) },
+            Some(tok) => quote! { Some( #tok.to_string() ) },
             None => quote! { None },
         };