From 6fdb2014c70e72c08a8d6d6e431145c5dc205669 Mon Sep 17 00:00:00 2001 From: nojaf Date: Thu, 8 Apr 2021 11:06:26 +0200 Subject: [PATCH] Add regression test. Fixes #1610. --- src/Fantomas.Tests/LetBindingTests.fs | 109 ++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) diff --git a/src/Fantomas.Tests/LetBindingTests.fs b/src/Fantomas.Tests/LetBindingTests.fs index 4cb4ec4a96..af5a798401 100644 --- a/src/Fantomas.Tests/LetBindingTests.fs +++ b/src/Fantomas.Tests/LetBindingTests.fs @@ -1683,3 +1683,112 @@ stepLog.LogInformation ( ThingThingThing.go options |> BlahBlah foo in a) ) """ + +[] +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 runTest + |> ignore + + let bar2 () = + + let f1 = () + + let runTest () = + let (Thing f) = + [ a ; b ] |> Blah.tryConcat |> Option.get in f () |> ignore + + Assert.Throws 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 runTest |> ignore + + let bar2 () = + + let f1 = () + + let runTest () = + let (Thing f) = + [ a ; b ] |> Blah.tryConcat |> Option.get in f () |> ignore + + Assert.Throws runTest |> ignore +""" + +[] +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 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 runTest |> ignore +"""