From 6717c9aef6726c873001b6a888c1f1684849163d Mon Sep 17 00:00:00 2001 From: Giacomo Cavalieri Date: Mon, 7 Oct 2024 17:20:11 +0200 Subject: [PATCH] echo format tests --- compiler-core/src/format/tests.rs | 202 ++++++++++++++++++++++++++++++ 1 file changed, 202 insertions(+) diff --git a/compiler-core/src/format/tests.rs b/compiler-core/src/format/tests.rs index 063ae63c779..c96698c2918 100644 --- a/compiler-core/src/format/tests.rs +++ b/compiler-core/src/format/tests.rs @@ -6435,3 +6435,205 @@ fn big_grapheme_cluster() { "# ); } + +#[test] +fn echo() { + assert_format!( + "fn main() { + echo +} +" + ); +} + +#[test] +fn echo_with_value() { + assert_format!( + r#"fn main() { + echo value +} +"# + ); +} + +#[test] +fn echo_with_big_value_that_needs_to_be_split() { + assert_format!( + r#"fn main() { + echo [ + this_is_a_long_list_and_requires_splitting, + wibble_wobble_woo, + multiple_lines, + ] +} +"# + ); +} + +#[test] +fn echo_inside_a_pipeline() { + assert_format!( + r#"fn main() { + wibble + |> echo + |> wobble +} +"# + ); +} + +#[test] +fn echo_with_value_inside_a_pipeline() { + assert_format!( + r#"fn main() { + wibble + |> echo value + |> wobble +} +"# + ); +} + +#[test] +fn echo_with_long_value_inside_a_pipeline() { + assert_format_rewrite!( + r#"fn main() { + wibble + |> echo this_is_a_looooooooong_value(that_get_split_on_multiple_lines, i_wonder_how_this_will_look) + |> wobble +} +"#, + r#"fn main() { + wibble + |> echo this_is_a_looooooooong_value( + that_get_split_on_multiple_lines, + i_wonder_how_this_will_look, + ) + |> wobble +} +"#, + ); +} + +#[test] +fn echo_inside_a_single_line_pipeline() { + assert_format!( + r#"fn main() { + wibble |> echo |> wobble +} +"# + ); +} + +#[test] +fn echo_with_value_inside_a_single_line_pipeline() { + assert_format!( + r#"fn main() { + wibble |> echo value |> wobble +} +"# + ); +} + +#[test] +fn echo_with_long_value_inside_a_single_line_pipeline() { + assert_format_rewrite!( + r#"fn main() { + wibble |> echo this_is_a_looooooooong_value(that_get_split_on_multiple_lines, i_wonder_how_this_will_look) |> wobble +} +"#, + r#"fn main() { + wibble + |> echo this_is_a_looooooooong_value( + that_get_split_on_multiple_lines, + i_wonder_how_this_will_look, + ) + |> wobble +} +"# + ); +} + +#[test] +fn echo_as_last_item_of_pipeline() { + assert_format!( + r#"fn main() { + wibble |> wobble |> echo +} +"# + ); +} + +#[test] +fn echo_with_value_as_last_item_of_pipeline() { + assert_format!( + r#"fn main() { + wibble |> wobble |> echo value +} +"# + ); +} + +#[test] +fn echo_with_long_value_as_last_item_of_pipeline() { + assert_format_rewrite!( + r#"fn main() { + wibble |> wobble |> echo this_is_a_looooooooong_value(that_get_split_on_multiple_lines, i_wonder_how_this_will_look) +} +"#, + r#"fn main() { + wibble + |> wobble + |> echo this_is_a_looooooooong_value( + that_get_split_on_multiple_lines, + i_wonder_how_this_will_look, + ) +} +"# + ); +} + +#[test] +fn echo_as_last_item_of_multiline_pipeline() { + assert_format!( + r#"fn main() { + wibble + |> wobble + |> echo +} +"# + ); +} + +#[test] +fn echo_with_value_as_last_item_of_multiline_pipeline() { + assert_format!( + r#"fn main() { + wibble + |> wobble + |> echo value +} +"# + ); +} + +#[test] +fn echo_with_long_value_as_last_item_of_multiline_pipeline() { + assert_format_rewrite!( + r#"fn main() { + wibble + |> wobble + |> echo this_is_a_looooooooong_value(that_get_split_on_multiple_lines, i_wonder_how_this_will_look) +} +"#, + r#"fn main() { + wibble + |> wobble + |> echo this_is_a_looooooooong_value( + that_get_split_on_multiple_lines, + i_wonder_how_this_will_look, + ) +} +"# + ); +}