wrong.rs 1.6 KB

1234567891011121314151617181920212223242526272829303132
  1. use dioxus_autofmt::{IndentOptions, IndentType};
  2. macro_rules! twoway {
  3. ($val:literal => $name:ident ($indent:expr)) => {
  4. #[test]
  5. fn $name() {
  6. let src_right = include_str!(concat!("./wrong/", $val, ".rsx"));
  7. let src_wrong = include_str!(concat!("./wrong/", $val, ".wrong.rsx"));
  8. let formatted = dioxus_autofmt::fmt_file(src_wrong, $indent);
  9. let out = dioxus_autofmt::apply_formats(src_wrong, formatted);
  10. // normalize line endings
  11. let out = out.replace("\r", "");
  12. let src_right = src_right.replace("\r", "");
  13. pretty_assertions::assert_eq!(&src_right, &out);
  14. }
  15. };
  16. }
  17. twoway!("comments-4sp" => comments_4sp (IndentOptions::new(IndentType::Spaces, 4, false)));
  18. twoway!("comments-tab" => comments_tab (IndentOptions::new(IndentType::Tabs, 4, false)));
  19. twoway!("multi-4sp" => multi_4sp (IndentOptions::new(IndentType::Spaces, 4, false)));
  20. twoway!("multi-tab" => multi_tab (IndentOptions::new(IndentType::Tabs, 4, false)));
  21. twoway!("multiexpr-4sp" => multiexpr_4sp (IndentOptions::new(IndentType::Spaces, 4, false)));
  22. twoway!("multiexpr-tab" => multiexpr_tab (IndentOptions::new(IndentType::Tabs, 4, false)));
  23. twoway!("multiexpr-many" => multiexpr_many (IndentOptions::new(IndentType::Spaces, 4, false)));
  24. twoway!("simple-combo-expr" => simple_combo_expr (IndentOptions::new(IndentType::Spaces, 4, false)));
  25. twoway!("oneline-expand" => online_expand (IndentOptions::new(IndentType::Spaces, 4, false)));
  26. twoway!("shortened" => shortened (IndentOptions::new(IndentType::Spaces, 4, false)));