Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep spaces for named arguments #2038

Merged
merged 13 commits into from
Feb 11, 2022
28 changes: 28 additions & 0 deletions src/Fantomas.Tests/AppTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -751,3 +751,31 @@ x |> f<y> // some comment
"""
x |> f<y> // some comment
"""

[<Test>]
let ``single named arguments should have space surrounding the '=', 1877`` () =
formatSourceString
false
"""
let makeStreamReader x = new System.IO.StreamReader(path=x)"""
config
|> prepend newline
|> should
equal
"""
let makeStreamReader x = new System.IO.StreamReader(path = x)
"""

[<Test>]
let ``multiple named arguments should have space surrounding the '=', 1877`` () =
formatSourceString
false
"""
let makeStreamReader x y = new StreamReader(arg1=x, arg2=y)"""
config
|> prepend newline
|> should
equal
"""
let makeStreamReader x y = new StreamReader(arg1 = x, arg2 = y)
"""
20 changes: 20 additions & 0 deletions src/Fantomas.Tests/PatternMatchingTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2047,3 +2047,23 @@ match!
| None -> false
| Some balance -> someRetrievedBalance = balance
"""

[<Test>]
let ``single line named fields in a pattern matching should have space surrounding the '=', 1877`` () =
formatSourceString
false
"""
let examineData x =
match data with
| OnePartData(part1 = p1) -> p1
| TwoPartData(part1 = p1; part2=p2) -> p1 + p2"""
config
|> prepend newline
|> should
equal
"""
let examineData x =
match data with
| OnePartData (part1 = p1) -> p1
| TwoPartData (part1 = p1; part2 = p2) -> p1 + p2
"""