Skip to content

Commit

Permalink
Fix typo and add failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinSStewart authored and jfmengels committed Mar 25, 2021
1 parent cc065e1 commit 4ac9684
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Elm/Syntax/Expression.elm
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ type alias LetBlock =
}


{-| Union type for all possible declations in a let block
{-| Union type for all possible declarations in a let block
-}
type LetDeclaration
= LetFunction Function
Expand Down
40 changes: 40 additions & 0 deletions tests/tests/Elm/Parser/DeclarationsTests.elm
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,46 @@ all =
}
}
)
, test "let destructuring with no spaces around '='" <|
\() ->
parseFullStringWithNullState "foo =\n let\n (b, c)=(1, 2)\n in\n b" Parser.function
|> Maybe.map Node.value
|> Maybe.map noRangeDeclaration
|> Expect.equal
(Just <|
FunctionDeclaration
{ signature = Nothing
, documentation = Nothing
, declaration =
Node emptyRange <|
{ name = Node emptyRange "foo"
, arguments = []
, expression =
Node emptyRange <|
LetExpression
{ declarations =
[ Node emptyRange <|
LetDestructuring
(Node emptyRange
(TuplePattern
[ Node emptyRange (VarPattern "b")
, Node emptyRange (VarPattern "c")
]
)
)
(Node emptyRange
(TupledExpression
[ Node emptyRange (Integer 1)
, Node emptyRange (Integer 2)
]
)
)
]
, expression = Node emptyRange <| FunctionOrValue [] "b"
}
}
}
)
, test "declaration with record" <|
\() ->
parseFullStringWithNullState "main =\n beginnerProgram { model = 0, view = view, update = update }" Parser.function
Expand Down

0 comments on commit 4ac9684

Please sign in to comment.