Skip to content

Commit

Permalink
Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GearsDatapacks authored and lpil committed Jan 16, 2025
1 parent bd89992 commit d2e47de
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
15 changes: 15 additions & 0 deletions compiler-core/src/language_server/tests/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1886,3 +1886,18 @@ pub fn map(_, _) { [] }
Position::new(3, 8)
);
}

#[test]
fn case_subject() {
let code = "
pub fn main(something: Bool) {
case so
}
";

assert_apply_completion!(
TestProject::for_source(code),
"something",
Position::new(2, 9)
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
source: compiler-core/src/language_server/tests/completion.rs
expression: "\npub fn main(something: Bool) {\n case so\n}\n"
---
pub fn main(something: Bool) {
case so|
}


----- After applying completion -----

pub fn main(something: Bool) {
case something
}
5 changes: 5 additions & 0 deletions compiler-core/src/type_/tests/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2685,3 +2685,8 @@ fn negative_out_of_range_erlang_float_in_pattern() {
fn negative_out_of_range_erlang_float_in_const() {
assert_module_error!(r#"const x = -1.8e308"#);
}

#[test]
fn missing_case_body() {
assert_error!("case True");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
source: compiler-core/src/type_/tests/errors.rs
expression: case True
---
----- SOURCE CODE
case True

----- ERROR
error: Missing case body
┌─ /src/one/two.gleam:1:1
1case True
^^^^^^^^^

This case expression is missing its body.

0 comments on commit d2e47de

Please sign in to comment.