Skip to content

Commit

Permalink
Formatter tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lpil committed Nov 27, 2024
1 parent 11872f5 commit 701b83c
Show file tree
Hide file tree
Showing 2 changed files with 355 additions and 206 deletions.
207 changes: 1 addition & 206 deletions compiler-core/src/format/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ mod bit_array;
mod blocks;
mod cases;
mod conditional_compilation;
mod custom_type;
mod external_fn;
mod external_types;
mod function;
Expand Down Expand Up @@ -257,85 +258,6 @@ type Many(a) =
);
}

#[test]
fn custom_types() {
assert_format!(
"type WowThisTypeHasJustTheLongestName(
some_long_type_variable,
and_another,
and_another_again,
) {
Make
}
"
);

assert_format!(
"type Result(a, e) {
Ok(a)
Error(e)
}
"
);

assert_format!(
"type Result(a, e) {
Ok(value: a)
Error(error: e)
}
"
);

assert_format!(
"type SillyResult(a, e) {
Ok(
first_value_with_really_long_name: a,
second_value_with_really_long_name: a,
)
Error(error: e)
}
"
);

assert_format!(
"type SillyResult(a, e) {
Ok(
first_value_with_really_long_name: a,
second_value_with_really_long_name: List(
#(Int, fn(a, a, a, a, a, a, a) -> List(a)),
),
)
Error(error: e)
}
"
);

assert_format!(
"type X {
X(
start: fn() -> a_reall_really_long_name_goes_here,
stop: fn() -> a_reall_really_long_name_goes_here,
)
}
"
);

assert_format!(
"pub opaque type X {
X
}
"
);

assert_format!(
"///
pub type Option(a) {
None
}
"
);
}

#[test]
fn expr_fn() {
assert_format!(
Expand Down Expand Up @@ -3325,49 +3247,6 @@ type Whatever =
);
}

#[test]
fn doc_comments_7_test() {
assert_format!(
r#"import one
/// one
///two
type Whatever {
Whatever
}
"#
);
}

#[test]
fn comments1() {
assert_format!(
r#"import one
// one
//two
type Whatever {
Whatever
}
"#
);
}

#[test]
fn comments2() {
assert_format!(
r#"import one
// one
//two
/// three
type Whatever {
Whatever
}
"#
);
}

#[test]
fn comments3() {
assert_format!(
Expand Down Expand Up @@ -3402,38 +3281,6 @@ fn whatever() -> Nil
);
}

#[test]
fn comments6() {
assert_format!(
r#"// one
//two
type Thingy
"#
);
}

#[test]
fn comments7() {
assert_format!(
r#"// one
//two
type Thingy
"#
);
}

#[test]
fn comments8() {
assert_format!(
r#"// one
//two
type Whatever {
Whatever
}
"#
);
}

#[test]
fn comments9() {
assert_format!(
Expand All @@ -3445,29 +3292,6 @@ type Whatever =
);
}

#[test]
fn comments10() {
assert_format!(
r#"// zero
import one
// one
//two
type Whatever {
Whatever
}
"#
);

assert_format!(
"fn main() {
// Hello
\"world\"
}
"
);
}

#[test]
fn comment23() {
assert_format!(
Expand Down Expand Up @@ -4936,24 +4760,6 @@ pub fn main() {
);
}

// https://github.com/gleam-lang/gleam/issues/1757
#[test]
fn multiple_line_custom_type_constructor_field_doc_comments() {
assert_format!(
r#"pub type Thingy {
Thingy(
/// One?
/// One!
one: One,
/// Two?
/// Two!
two: Two,
)
}
"#
);
}

// https://github.com/gleam-lang/gleam/issues/1872
#[test]
fn multiple_line_spread_list_comments() {
Expand Down Expand Up @@ -5361,17 +5167,6 @@ fn comment_at_end_of_type() {
);
}

#[test]
fn deprecated_custom_type() {
assert_format!(
r#"@deprecated("Deprecated type")
pub type One {
One
}
"#
);
}

#[test]
fn deprecated_type_alias() {
assert_format!(
Expand Down
Loading

0 comments on commit 701b83c

Please sign in to comment.