dioxus/packages/autofmt/tests/samples.rs

49 lines
1,023 B
Rust
Raw Normal View History

macro_rules! twoway {
2023-01-13 00:29:31 +00:00
(
$(
// doc attrs
$( #[doc = $doc:expr] )*
2023-06-02 17:03:56 +00:00
$name:ident,
)*
2023-01-13 00:29:31 +00:00
) => {
$(
$( #[doc = $doc] )*
#[test]
fn $name() {
let src = include_str!(concat!("./samples/", stringify!($name), ".rsx"));
let formatted = dioxus_autofmt::fmt_file(src);
let out = dioxus_autofmt::apply_formats(src, formatted);
2023-06-02 17:03:56 +00:00
// normalize line endings
let out = out.replace("\r", "");
let src = src.replace("\r", "");
2023-01-13 00:29:31 +00:00
pretty_assertions::assert_eq!(&src, &out);
}
)*
};
}
2023-01-13 00:29:31 +00:00
twoway![
attributes,
2023-06-02 17:03:56 +00:00
collapse_expr,
comments,
2023-01-13 00:29:31 +00:00
commentshard,
2023-06-02 17:03:56 +00:00
complex,
emoji,
ifchain_forloop,
immediate_expr,
2023-06-02 17:03:56 +00:00
key,
long_exprs,
long,
manual_props,
messy_indent,
multirsx,
raw_strings,
reallylong,
simple,
t2,
tiny,
tinynoopt,
trailing_expr,
2023-01-13 00:29:31 +00:00
];