parse and format pattern as

This commit is contained in:
Folkert 2022-12-30 17:50:17 +01:00
parent ea53a50447
commit e9196f3c0b
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
13 changed files with 189 additions and 7 deletions

View file

@ -0,0 +1,31 @@
When(
@5-6 Num(
"0",
),
[
WhenBranch {
patterns: [
@14-20 SpaceBefore(
As(
@14-15 SpaceAfter(
Underscore(
"",
),
[],
),
[],
@19-20 "n",
),
[
Newline,
],
),
],
value: @24-25 Var {
module_name: "",
ident: "n",
},
guard: None,
},
],
)

View file

@ -0,0 +1,2 @@
when 0 is
_ as n -> n

View file

@ -0,0 +1,38 @@
When(
@5-6 Num(
"0",
),
[
WhenBranch {
patterns: [
@14-54 SpaceBefore(
As(
@14-15 SpaceAfter(
NumLiteral(
"0",
),
[
LineComment(
" foobar",
),
],
),
[
LineComment(
" barfoo",
),
],
@53-54 "n",
),
[
Newline,
],
),
],
value: @58-60 Record(
[],
),
guard: None,
},
],
)

View file

@ -0,0 +1,4 @@
when 0 is
0 # foobar
as # barfoo
n -> {}

View file

@ -354,6 +354,8 @@ mod test_snapshots {
pass/parenthetical_var.expr,
pass/parse_alias.expr,
pass/parse_as_ann.expr,
pass/pattern_as.expr,
pass/pattern_as_spaces.expr,
pass/pattern_with_space_in_parens.expr, // https://github.com/roc-lang/roc/issues/929
pass/plus_if.expr,
pass/plus_when.expr,