Skip to content

Commit

Permalink
Add regression test. Fixes fsprojects#1610.
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf committed Apr 8, 2021
1 parent df30be1 commit 6fdb201
Showing 1 changed file with 109 additions and 0 deletions.
109 changes: 109 additions & 0 deletions src/Fantomas.Tests/LetBindingTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1683,3 +1683,112 @@ stepLog.LogInformation (
ThingThingThing.go options |> BlahBlah foo in a)
)
"""

[<Test>]
let ``in keyword in let binding should stay in one line, 1610`` () =
formatSourceString
false
"""
module Foo =
let bar () =
let f1 = ()
let runTest () = let (Thing f) = [a;b] |> Blah.tryConcat |> Option.get in f () |> ignore
Assert.Throws<exn> runTest
|> ignore
let bar2 () =
let f1 = ()
let runTest () =
let (Thing f) =
[ a ; b ] |> Blah.tryConcat |> Option.get in f () |> ignore
Assert.Throws<exn> runTest |> ignore
"""
{ config with
MaxLineLength = 100
SpaceBeforeUppercaseInvocation = true
SpaceBeforeClassConstructor = true
SpaceBeforeMember = true
SpaceBeforeColon = true
SpaceBeforeSemicolon = true
MultilineBlockBracketsOnSameColumn = true
NewlineBetweenTypeDefinitionAndMembers = true
KeepIfThenInSameLine = true
AlignFunctionSignatureToIndentation = true
AlternativeLongMemberDefinitions = true
MultiLineLambdaClosingNewline = true
KeepIndentInBranch = true }
|> prepend newline
|> should
equal
"""
module Foo =
let bar () =
let f1 = ()
let runTest () =
let (Thing f) =
[ a ; b ] |> Blah.tryConcat |> Option.get in f () |> ignore
Assert.Throws<exn> runTest |> ignore
let bar2 () =
let f1 = ()
let runTest () =
let (Thing f) =
[ a ; b ] |> Blah.tryConcat |> Option.get in f () |> ignore
Assert.Throws<exn> runTest |> ignore
"""

[<Test>]
let ``mhex xx 2`` () =
formatSourceString
false
"""
module Foo =
let bar () =
let f1 = ()
let runTest () =
let (Thing f) =
[ a ; b ] |> Blah.tryConcat |> Option.get in f () |> ignore
Assert.Throws<exn> runTest |> ignore
"""
{ config with
MaxLineLength = 100
SpaceBeforeUppercaseInvocation = true
SpaceBeforeClassConstructor = true
SpaceBeforeMember = true
SpaceBeforeColon = true
SpaceBeforeSemicolon = true
MultilineBlockBracketsOnSameColumn = true
NewlineBetweenTypeDefinitionAndMembers = true
KeepIfThenInSameLine = true
AlignFunctionSignatureToIndentation = true
AlternativeLongMemberDefinitions = true
MultiLineLambdaClosingNewline = true
KeepIndentInBranch = true }
|> prepend newline
|> should
equal
"""
module Foo =
let bar () =
let f1 = ()
let runTest () =
let (Thing f) =
[ a ; b ] |> Blah.tryConcat |> Option.get in f () |> ignore
Assert.Throws<exn> runTest |> ignore
"""

0 comments on commit 6fdb201

Please sign in to comment.