1
0

hotreloads.rs 847 B

12345678910111213141516171819202122232425262728293031
  1. use dioxus_rsx_hotreload::diff_rsx;
  2. use syn::File;
  3. macro_rules! assert_rsx_changed {
  4. (
  5. $( #[doc = $doc:expr] )*
  6. $name:ident
  7. ) => {
  8. $( #[doc = $doc] )*
  9. #[test]
  10. fn $name() {
  11. let old = include_str!(concat!("./valid/", stringify!($name), ".old.rsx"));
  12. let new = include_str!(concat!("./valid/", stringify!($name), ".new.rsx"));
  13. let (old, new) = load_files(old, new);
  14. assert!(diff_rsx(&new, &old).is_some());
  15. }
  16. };
  17. }
  18. fn load_files(old: &str, new: &str) -> (File, File) {
  19. let old = syn::parse_file(old).unwrap();
  20. let new = syn::parse_file(new).unwrap();
  21. (old, new)
  22. }
  23. assert_rsx_changed![combo];
  24. assert_rsx_changed![expr];
  25. assert_rsx_changed![for_];
  26. assert_rsx_changed![if_];
  27. assert_rsx_changed![let_];
  28. assert_rsx_changed![nested];