2023-11-01 00:48:19 +00:00
|
|
|
use dioxus_autofmt::{IndentType, IndentOptions};
|
|
|
|
|
2022-07-05 21:59:33 +00:00
|
|
|
macro_rules! twoway {
|
2023-11-01 00:48:19 +00:00
|
|
|
($val:literal => $name:ident ($indent:expr)) => {
|
2022-07-05 21:59:33 +00:00
|
|
|
#[test]
|
|
|
|
fn $name() {
|
|
|
|
let src_right = include_str!(concat!("./wrong/", $val, ".rsx"));
|
|
|
|
let src_wrong = include_str!(concat!("./wrong/", $val, ".wrong.rsx"));
|
2023-11-01 00:48:19 +00:00
|
|
|
let formatted = dioxus_autofmt::fmt_file(src_wrong, $indent);
|
2022-07-05 21:59:33 +00:00
|
|
|
let out = dioxus_autofmt::apply_formats(src_wrong, formatted);
|
2023-06-02 17:03:56 +00:00
|
|
|
|
|
|
|
// normalize line endings
|
|
|
|
let out = out.replace("\r", "");
|
|
|
|
let src_right = src_right.replace("\r", "");
|
|
|
|
|
2022-07-05 21:59:33 +00:00
|
|
|
pretty_assertions::assert_eq!(&src_right, &out);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-11-01 00:48:19 +00:00
|
|
|
twoway!("comments-4sp" => comments_4sp (IndentOptions::new(IndentType::Spaces, 4)));
|
|
|
|
twoway!("comments-tab" => comments_tab (IndentOptions::new(IndentType::Tabs, 4)));
|
2022-07-07 06:06:50 +00:00
|
|
|
|
2023-11-01 00:48:19 +00:00
|
|
|
twoway!("multi-4sp" => multi_4sp (IndentOptions::new(IndentType::Spaces, 4)));
|
|
|
|
twoway!("multi-tab" => multi_tab (IndentOptions::new(IndentType::Tabs, 4)));
|
2022-09-28 23:47:10 +00:00
|
|
|
|
2023-11-01 00:48:19 +00:00
|
|
|
twoway!("multiexpr-4sp" => multiexpr_4sp (IndentOptions::new(IndentType::Spaces, 4)));
|
|
|
|
twoway!("multiexpr-tab" => multiexpr_tab (IndentOptions::new(IndentType::Tabs, 4)));
|