mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 04:08:19 +00:00
New Lambda Syntax with |...|
This adds parser support for the new lambda syntax. It does not remove the existing syntax, nor will the new syntax be retained in formatting. That will be done in a separate PR to keep the two respective PRs relatively small and easy to review.
This commit is contained in:
parent
4e66910ef8
commit
8e1e1520e3
6 changed files with 172 additions and 50 deletions
|
@ -1778,41 +1778,80 @@ mod test_fmt {
|
|||
|
||||
#[test]
|
||||
fn lambda_returns_record_new_syntax() {
|
||||
expr_formats_same(indoc!(
|
||||
r"
|
||||
to_record = |_| {
|
||||
x: 1,
|
||||
y: 2,
|
||||
z: 3,
|
||||
}
|
||||
|
||||
to_record
|
||||
"
|
||||
));
|
||||
|
||||
expr_formats_same(indoc!(
|
||||
r"
|
||||
func = |_|
|
||||
{ x: 1, y: 2, z: 3 }
|
||||
|
||||
func
|
||||
"
|
||||
));
|
||||
|
||||
expr_formats_same(indoc!(
|
||||
r"
|
||||
to_record = |_|
|
||||
val = 0
|
||||
|
||||
{
|
||||
expr_formats_to(
|
||||
indoc!(
|
||||
r"
|
||||
to_record = |_| {
|
||||
x: 1,
|
||||
y: 2,
|
||||
z: 3,
|
||||
}
|
||||
|
||||
to_record
|
||||
"
|
||||
));
|
||||
to_record
|
||||
"
|
||||
),
|
||||
indoc!(
|
||||
r"
|
||||
to_record = \_ -> {
|
||||
x: 1,
|
||||
y: 2,
|
||||
z: 3,
|
||||
}
|
||||
|
||||
to_record
|
||||
"
|
||||
),
|
||||
);
|
||||
|
||||
expr_formats_to(
|
||||
indoc!(
|
||||
r"
|
||||
func = |_|
|
||||
{ x: 1, y: 2, z: 3 }
|
||||
|
||||
func
|
||||
"
|
||||
),
|
||||
indoc!(
|
||||
r"
|
||||
func = \_ ->
|
||||
{ x: 1, y: 2, z: 3 }
|
||||
|
||||
func
|
||||
"
|
||||
),
|
||||
);
|
||||
|
||||
expr_formats_to(
|
||||
indoc!(
|
||||
r"
|
||||
to_record = |_|
|
||||
val = 0
|
||||
|
||||
{
|
||||
x: 1,
|
||||
y: 2,
|
||||
z: 3,
|
||||
}
|
||||
|
||||
to_record
|
||||
"
|
||||
),
|
||||
indoc!(
|
||||
r"
|
||||
to_record = \_ ->
|
||||
val = 0
|
||||
|
||||
{
|
||||
x: 1,
|
||||
y: 2,
|
||||
z: 3,
|
||||
}
|
||||
|
||||
to_record
|
||||
"
|
||||
),
|
||||
);
|
||||
|
||||
expr_formats_to(
|
||||
indoc!(
|
||||
|
@ -1829,7 +1868,7 @@ mod test_fmt {
|
|||
),
|
||||
indoc!(
|
||||
r"
|
||||
to_record = |_| {
|
||||
to_record = \_ -> {
|
||||
x: 1,
|
||||
y: 2,
|
||||
z: 3,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue