New module header

Implements the new `module` header syntax as described in "module and package changes" [1]:

```
module [Request, Response, req]
```

The old syntax should still work fine, and is automatically upgraded to the new one
when running `roc format`.

[1] https://docs.google.com/document/d/1E_77fO-44BtoBtXoVeWyGh1xN2KRTWTu8q6i25RNNx0/edit
This commit is contained in:
Agus Zubiaga 2024-02-18 19:10:54 -03:00
parent 7754dd7ef7
commit 057a18573a
No known key found for this signature in database
92 changed files with 1445 additions and 1563 deletions

View file

@ -4768,10 +4768,10 @@ mod test_fmt {
// MODULES
#[test]
fn single_line_interface() {
fn single_line_module() {
module_formats_same(indoc!(
r"
interface Foo exposes [] imports []"
module []"
));
}
@ -4781,12 +4781,14 @@ mod test_fmt {
module_formats_to(
indoc!(
r"
interface Foo exposes [] imports []
module []
a = 42 # Yay greetings"
),
indoc!(
r"
interface Foo exposes [] imports []
module []
a = 42 # Yay greetings
"
),
@ -4794,49 +4796,25 @@ mod test_fmt {
}
#[test]
fn multiline_interface() {
fn module_exposing() {
module_formats_same(indoc!(
r"
interface Foo
exposes []
imports []"
module [Bar, Baz, a, b]"
));
}
#[test]
fn interface_exposing() {
fn module_exposing_multiline() {
module_formats_same(indoc!(
r"
interface Foo
exposes [Bar, Baz, a, b]
imports []"
));
}
module [
Stuff,
Things,
somethingElse,
]
#[test]
fn interface_importing() {
module_formats_same(indoc!(
r"
interface Foo
exposes [Bar, Baz, a, b]
imports [Blah, Thing.{ foo, bar }, Stuff]"
));
}
#[test]
fn multi_line_interface() {
module_formats_same(indoc!(
r"
interface Foo
exposes [
Stuff,
Things,
somethingElse,
]
imports [
Blah,
Baz.{ stuff, things },
]"
import Blah
import Baz exposing [stuff, things]"
));
}
@ -4866,9 +4844,7 @@ mod test_fmt {
&format!(
indoc!(
r#"
interface Foo
exposes []
imports []
module []
# comment 1{space}
def = "" # comment 2{space}
@ -4879,9 +4855,7 @@ mod test_fmt {
),
indoc!(
r#"
interface Foo
exposes []
imports []
module []
# comment 1
def = "" # comment 2
@ -5700,7 +5674,7 @@ mod test_fmt {
module_formats_same(indoc!(
r"
interface Foo exposes [] imports []
module []
expect x == y
@ -5727,7 +5701,7 @@ mod test_fmt {
module_formats_same(indoc!(
r"
interface Foo exposes [] imports []
module []
expect
foo bar
@ -5831,7 +5805,7 @@ mod test_fmt {
fn ability_member_doc_comments() {
module_formats_same(indoc!(
r"
interface Foo exposes [] imports []
module []
A implements
## This is member ab
@ -5850,9 +5824,7 @@ mod test_fmt {
module_formats_same(indoc!(
r"
# hello world
interface Foo
exposes []
imports []
module []
"
));
@ -5876,6 +5848,17 @@ mod test_fmt {
));
}
#[test]
fn comments_before_exposes_preserved() {
module_formats_same(indoc!(
r"
module
# comment
[a, b]
"
));
}
#[test]
fn clauses_with_multiple_abilities() {
expr_formats_same(indoc!(