rsx.rs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #[test]
  2. fn rsx() {
  3. let t = trybuild::TestCases::new();
  4. t.compile_fail("tests/rsx/trailing-comma-0.rs");
  5. }
  6. /// This test ensures that automatic `into` conversion occurs for default values.
  7. ///
  8. /// These are compile-time tests.
  9. /// See https://github.com/DioxusLabs/dioxus/issues/2373
  10. #[cfg(test)]
  11. mod test_default_into {
  12. use dioxus::prelude::*;
  13. #[derive(Props, Clone, PartialEq)]
  14. struct MyCoolProps {
  15. // Test different into configurations
  16. #[props(into, default = true)]
  17. pub val_into_w_default_val: u16,
  18. #[props(into, default)]
  19. pub val_into_w_default: u16,
  20. #[props(default = true.into())]
  21. pub val_default: u16,
  22. // Test different into configurations with strings
  23. #[props(into, default = "abc")]
  24. pub str_into_w_default_val: String,
  25. #[props(into, default)]
  26. pub str_into_w_default: String,
  27. #[props(default = "abc".into())]
  28. pub str_default: String,
  29. // Test options
  30. #[props(into, default = Some("abc"))]
  31. pub opt_into_w_default_val: Option<String>,
  32. #[props(into, default)]
  33. pub opt_into_w_default: Option<String>,
  34. #[props(default = Some("abc"))]
  35. pub opt_default: Option<String>,
  36. // Test no default
  37. #[props(into)]
  38. pub some_data: bool,
  39. pub some_other_data: bool,
  40. }
  41. }