1
0

wrong.rs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #![allow(deprecated)]
  2. use dioxus_autofmt::{IndentOptions, IndentType};
  3. macro_rules! twoway {
  4. ($val:literal => $name:ident ($indent:expr)) => {
  5. #[test]
  6. fn $name() {
  7. let src_right = include_str!(concat!("./wrong/", $val, ".rsx"));
  8. let src_wrong = include_str!(concat!("./wrong/", $val, ".wrong.rsx"));
  9. let parsed = syn::parse_file(src_wrong)
  10. .expect("fmt_file should only be called on valid syn::File files");
  11. let formatted =
  12. dioxus_autofmt::try_fmt_file(src_wrong, &parsed, $indent).unwrap_or_default();
  13. let out = dioxus_autofmt::apply_formats(src_wrong, formatted);
  14. // normalize line endings
  15. let out = out.replace("\r", "");
  16. let src_right = src_right.replace("\r", "");
  17. pretty_assertions::assert_eq!(&src_right, &out);
  18. }
  19. };
  20. }
  21. twoway!("comments-4sp" => comments_4sp (IndentOptions::new(IndentType::Spaces, 4, false)));
  22. twoway!("comments-tab" => comments_tab (IndentOptions::new(IndentType::Tabs, 4, false)));
  23. twoway!("multi-4sp" => multi_4sp (IndentOptions::new(IndentType::Spaces, 4, false)));
  24. twoway!("multi-tab" => multi_tab (IndentOptions::new(IndentType::Tabs, 4, false)));
  25. twoway!("multiexpr-4sp" => multiexpr_4sp (IndentOptions::new(IndentType::Spaces, 4, false)));
  26. twoway!("multiexpr-tab" => multiexpr_tab (IndentOptions::new(IndentType::Tabs, 4, false)));
  27. twoway!("multiexpr-many" => multiexpr_many (IndentOptions::new(IndentType::Spaces, 4, false)));
  28. twoway!("simple-combo-expr" => simple_combo_expr (IndentOptions::new(IndentType::Spaces, 4, false)));
  29. twoway!("oneline-expand" => online_expand (IndentOptions::new(IndentType::Spaces, 4, false)));
  30. twoway!("shortened" => shortened (IndentOptions::new(IndentType::Spaces, 4, false)));
  31. twoway!("syntax_error" => syntax_error (IndentOptions::new(IndentType::Spaces, 4, false)));
  32. twoway!("skipfail" => skipfail (IndentOptions::new(IndentType::Spaces, 4, false)));