@@ -384,11 +384,9 @@ let fold (funcs : ResultFunc<'Input, 'Output, 'TError> seq) (input : 'Input) : R
384384 MaxInfixOperatorExpression = 70 })
385385 |> prepend newline
386386 |> should equal """
387- let fold
388- (funcs : ResultFunc<'Input, 'Output, 'TError> seq)
389- (input : 'Input)
390- : Result<'Output list, 'TError list>
391- =
387+ let fold (funcs : ResultFunc<'Input, 'Output, 'TError> seq)
388+ (input : 'Input)
389+ : Result<'Output list, 'TError list> =
392390 let mutable anyErrors = false
393391 let mutable collectedOutputs = []
394392 let mutable collectedErrors = []
@@ -430,10 +428,9 @@ let ``internal keyword included in function signature length check`` () =
430428""" ({ config with MaxLineLength = 90 ; SpaceBeforeColon = true })
431429 |> prepend newline
432430 |> should equal """
433- let internal UpdateStrongNaming
434- (assembly : AssemblyDefinition)
435- (key : StrongNameKeyPair option)
436- =
431+ let internal UpdateStrongNaming (assembly : AssemblyDefinition)
432+ (key : StrongNameKeyPair option)
433+ =
437434 assembly.Name
438435
439436let UpdateStrongNamingX (assembly : AssemblyDefinition) (key : StrongNameKeyPair option) =
@@ -469,10 +466,9 @@ module FormatCode =
469466 CodeFormatter.FormatDocumentAsync("tmp.fsx", source, config, options, checker)
470467
471468 [<FunctionName("FormatCode")>]
472- let run
473- ([<HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "{*any}")>] req: HttpRequest)
474- (log: ILogger)
475- =
469+ let run ([<HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "{*any}")>] req: HttpRequest)
470+ (log: ILogger)
471+ =
476472 Http.main CodeFormatter.GetVersion format FormatConfig.FormatConfig.Default log req
477473"""
478474
@@ -505,11 +501,9 @@ module FormatCode =
505501 CodeFormatter.FormatDocumentAsync("tmp.fsx", source, config, options, checker)
506502
507503 [<FunctionName("FormatCode")>]
508- let run
509- ([<HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "{*any}")>] req: HttpRequest)
510- (log: ILogger)
511- : HttpResponse
512- =
504+ let run ([<HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "{*any}")>] req: HttpRequest)
505+ (log: ILogger)
506+ : HttpResponse =
513507 Http.main CodeFormatter.GetVersion format FormatConfig.FormatConfig.Default log req
514508"""
515509
@@ -526,14 +520,13 @@ let private addTaskToScheduler (scheduler : IScheduler) taskName taskCron prio (
526520""" ({ config with MaxLineLength = 100 })
527521 |> prepend newline
528522 |> should equal """
529- let private addTaskToScheduler
530- (scheduler: IScheduler)
531- taskName
532- taskCron
533- prio
534- (task: unit -> unit)
535- groupName
536- =
523+ let private addTaskToScheduler (scheduler: IScheduler)
524+ taskName
525+ taskCron
526+ prio
527+ (task: unit -> unit)
528+ groupName
529+ =
537530 let mutable jobDataMap = JobDataMap()
538531 jobDataMap.["task"] <- task
539532
@@ -551,11 +544,9 @@ let ``long function signature should align with equal sign, 883`` () =
551544""" { config with IndentSize = 2 ; SpaceBeforeColon = true }
552545 |> prepend newline
553546 |> should equal """
554- let readModel
555- (updateState : 'State -> EventEnvelope<'Event> list -> 'State)
556- (initState : 'State)
557- : ReadModel<'Event, 'State>
558- =
547+ let readModel (updateState : 'State -> EventEnvelope<'Event> list -> 'State)
548+ (initState : 'State)
549+ : ReadModel<'Event, 'State> =
559550 ()
560551"""
561552
@@ -566,9 +557,105 @@ let ``long function signature should align with equal sign, no return type`` ()
566557""" { config with IndentSize = 2 ; SpaceBeforeColon = true ; MaxLineLength = 80 }
567558 |> prepend newline
568559 |> should equal """
560+ let readModel (updateState : 'State -> EventEnvelope<'Event> list -> 'State)
561+ (initState : 'State)
562+ =
563+ ()
564+ """
565+
566+ [<Test>]
567+ let ``long function signature with single tuple parameter and no return type`` () =
568+ formatSourceString false """
569+ let fold (funcs: ResultFunc<'Input, 'Output, 'TError> seq, input: 'Input, input2: 'Input, input3: 'Input) =
570+ ()
571+ """ { config with MaxLineLength = 90 }
572+ |> prepend newline
573+ |> should equal """
574+ let fold (funcs: ResultFunc<'Input, 'Output, 'TError> seq,
575+ input: 'Input,
576+ input2: 'Input,
577+ input3: 'Input) =
578+ ()
579+ """
580+
581+ [<Test>]
582+ let ``long function signature with single tuple parameter and return type`` () =
583+ formatSourceString false """
584+ let fold (funcs: ResultFunc<'Input, 'Output, 'TError> seq, input: 'Input, input2: 'Input, input3: 'Input) : Result<'Output list, 'TError list> =
585+ ()
586+ """ { config with MaxLineLength = 90 }
587+ |> prepend newline
588+ |> should equal """
589+ let fold (funcs: ResultFunc<'Input, 'Output, 'TError> seq,
590+ input: 'Input,
591+ input2: 'Input,
592+ input3: 'Input)
593+ : Result<'Output list, 'TError list> =
594+ ()
595+ """
596+
597+ [<Test>]
598+ let ``align long function signature to indentation without return type `` () =
599+ formatSourceString false """
600+ let fold (funcs: ResultFunc<'Input, 'Output, 'TError> seq) (input: 'Input) (input2: 'Input) (input3: 'Input) = ()
601+ """ { config with MaxLineLength = 60 ; AlignFunctionSignatureToIndentation = true }
602+ |> prepend newline
603+ |> should equal """
604+ let fold
605+ (funcs: ResultFunc<'Input, 'Output, 'TError> seq)
606+ (input: 'Input)
607+ (input2: 'Input)
608+ (input3: 'Input)
609+ =
610+ ()
611+ """
612+
613+ [<Test>]
614+ let ``align long function signature to indentation with return type`` () =
615+ formatSourceString false """ let readModel (updateState : 'State -> EventEnvelope<'Event> list -> 'State) (initState : 'State) : ReadModel<'Event, 'State> =
616+ ()
617+ """ { config with IndentSize = 2 ; SpaceBeforeColon = true ; AlignFunctionSignatureToIndentation = true }
618+ |> prepend newline
619+ |> should equal """
569620let readModel
570621 (updateState : 'State -> EventEnvelope<'Event> list -> 'State)
571622 (initState : 'State)
623+ : ReadModel<'Event, 'State>
572624 =
573625 ()
574- """
626+ """
627+
628+ [<Test>]
629+ let ``align long function signature to indentation that are recursive`` () =
630+ formatSourceString false """
631+ let rec run ([<HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "{*any}")>] req: HttpRequest) (log: ILogger) : HttpResponse =
632+ logAnalyticsForRequest log req
633+ Http.main CodeFormatter.GetVersion format FormatConfig.FormatConfig.Default log req
634+
635+ and logAnalyticsForRequest (log:ILogger) (httpRequest: HttpRequest) =
636+ log.Info (sprintf "Meh: %A " httpRequest)
637+ """ { config with MaxLineLength = 60 ; AlignFunctionSignatureToIndentation = true }
638+ |> prepend newline
639+ |> should equal """
640+ let rec run
641+ ([<HttpTrigger(AuthorizationLevel.Anonymous,
642+ "get",
643+ "post",
644+ Route = "{*any}")>] req: HttpRequest)
645+ (log: ILogger)
646+ : HttpResponse
647+ =
648+ logAnalyticsForRequest log req
649+ Http.main
650+ CodeFormatter.GetVersion
651+ format
652+ FormatConfig.FormatConfig.Default
653+ log
654+ req
655+
656+ and logAnalyticsForRequest
657+ (log: ILogger)
658+ (httpRequest: HttpRequest)
659+ =
660+ log.Info(sprintf "Meh: %A " httpRequest)
661+ """
0 commit comments