diff --git a/src/Fantomas.Tests/FunctionDefinitionTests.fs b/src/Fantomas.Tests/FunctionDefinitionTests.fs index 9e8031dbdf..7a8173f889 100644 --- a/src/Fantomas.Tests/FunctionDefinitionTests.fs +++ b/src/Fantomas.Tests/FunctionDefinitionTests.fs @@ -411,4 +411,77 @@ let internal UpdateStrongNaming let UpdateStrongNamingX (assembly : AssemblyDefinition) (key : StrongNameKeyPair option) = assembly.Name +""" + +[] +let ``long function definition should put equals and body on a newline, 740`` () = + formatSourceString false """ +module FormatCode = + + let private format filename code config = + let checker = Fantomas.FakeHelpers.sharedChecker.Force() + let options = Fantomas.FakeHelpers.createParsingOptionsFromFile filename + let source = SourceOrigin.SourceString code + CodeFormatter.FormatDocumentAsync("tmp.fsx", source, config, options, checker) + + [] + let run ([] req: HttpRequest) (log: ILogger) = Http.main CodeFormatter.GetVersion format FormatConfig.FormatConfig.Default log req +""" config + |> prepend newline + |> should equal """ +module FormatCode = + + let private format filename code config = + let checker = + Fantomas.FakeHelpers.sharedChecker.Force() + + let options = + Fantomas.FakeHelpers.createParsingOptionsFromFile filename + + let source = SourceOrigin.SourceString code + CodeFormatter.FormatDocumentAsync("tmp.fsx", source, config, options, checker) + + [] + let run + ([] req: HttpRequest) + (log: ILogger) + = + Http.main CodeFormatter.GetVersion format FormatConfig.FormatConfig.Default log req +""" + +[] +let ``long function definition with return type should have multiline signature`` () = + formatSourceString false """ +module FormatCode = + + let private format filename code config = + let checker = Fantomas.FakeHelpers.sharedChecker.Force() + let options = Fantomas.FakeHelpers.createParsingOptionsFromFile filename + let source = SourceOrigin.SourceString code + CodeFormatter.FormatDocumentAsync("tmp.fsx", source, config, options, checker) + + [] + let run ([] req: HttpRequest) (log: ILogger) : HttpResponse = Http.main CodeFormatter.GetVersion format FormatConfig.FormatConfig.Default log req +""" config + |> prepend newline + |> should equal """ +module FormatCode = + + let private format filename code config = + let checker = + Fantomas.FakeHelpers.sharedChecker.Force() + + let options = + Fantomas.FakeHelpers.createParsingOptionsFromFile filename + + let source = SourceOrigin.SourceString code + CodeFormatter.FormatDocumentAsync("tmp.fsx", source, config, options, checker) + + [] + let run + ([] req: HttpRequest) + (log: ILogger) + : HttpResponse + = + Http.main CodeFormatter.GetVersion format FormatConfig.FormatConfig.Default log req """ \ No newline at end of file