Skip to content

Commit

Permalink
echo format tests
Browse files Browse the repository at this point in the history
  • Loading branch information
giacomocavalieri committed Oct 7, 2024
1 parent 9e947f5 commit 6717c9a
Showing 1 changed file with 202 additions and 0 deletions.
202 changes: 202 additions & 0 deletions compiler-core/src/format/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
}
"#
);
}

0 comments on commit 6717c9a

Please sign in to comment.