diff --git a/src/Fantomas.Tests/AttributeTests.fs b/src/Fantomas.Tests/AttributeTests.fs index 13744d2909..0661a80d1b 100644 --- a/src/Fantomas.Tests/AttributeTests.fs +++ b/src/Fantomas.Tests/AttributeTests.fs @@ -16,8 +16,7 @@ type Funcs = |> should equal """[] type Funcs = [] - static member ToFunc(f: Action<_, _, _>) = - Func<_, _, _, _>(fun a b c -> f.Invoke(a, b, c)) + static member ToFunc(f: Action<_, _, _>) = Func<_, _, _, _>(fun a b c -> f.Invoke(a, b, c)) """ [] diff --git a/src/Fantomas.Tests/ClassTests.fs b/src/Fantomas.Tests/ClassTests.fs index 172530e00d..66e2f21912 100644 --- a/src/Fantomas.Tests/ClassTests.fs +++ b/src/Fantomas.Tests/ClassTests.fs @@ -198,8 +198,7 @@ and File(filename: string, containingFolder: Folder) = type Folder(pathIn: string) = let path = pathIn let filenameArray: string array = System.IO.Directory.GetFiles(path) - member this.FileArray = - Array.map (fun elem -> new File(elem, this)) filenameArray + member this.FileArray = Array.map (fun elem -> new File(elem, this)) filenameArray and File(filename: string, containingFolder: Folder) = member __.Name = filename @@ -338,8 +337,7 @@ System.String.Concat("a", "b" + member __.Property = "hello" let longNamedFunlongNamedFunlongNamedFunlongNamedFunlongNamedFun (x: T) = x -let longNamedClasslongNamedClasslongNamedClasslongNamedClasslongNamedClasslongNamedClass = - T() +let longNamedClasslongNamedClasslongNamedClasslongNamedClasslongNamedClasslongNamedClass = T() System.String.Concat ("a", @@ -358,7 +356,5 @@ type Exception with |> should equal """open System type Exception with - member inline __.FirstLine = - (__.Message.Split - ([| Environment.NewLine |], StringSplitOptions.RemoveEmptyEntries)).[0] + member inline __.FirstLine = __.Message.Split([| Environment.NewLine |], StringSplitOptions.RemoveEmptyEntries).[0] """ \ No newline at end of file diff --git a/src/Fantomas.Tests/ComparisonTests.fs b/src/Fantomas.Tests/ComparisonTests.fs index a3acd43ad7..744490fd3a 100644 --- a/src/Fantomas.Tests/ComparisonTests.fs +++ b/src/Fantomas.Tests/ComparisonTests.fs @@ -20,8 +20,7 @@ let ``should keep the = on the same line in record def``() = let doRead (reader: JsonReader) = reader.Read() |> ignore override x.CanConvert(typ: Type) = let result = - ((typ.GetInterface(typeof.FullName) = null) - && FSharpType.IsUnion typ) + ((typ.GetInterface(typeof.FullName) = null) && FSharpType.IsUnion typ) result """ @@ -30,6 +29,5 @@ let ``should keep the = on the same line in record def``() = let ``should keep the = on the same line``() = formatSourceString false """trimSpecialChars(controller.ServerName.ToUpper()) = trimSpecialChars(serverFilter.ToUpper()) """ config - |> should equal """trimSpecialChars (controller.ServerName.ToUpper()) = trimSpecialChars - (serverFilter.ToUpper()) + |> should equal """trimSpecialChars (controller.ServerName.ToUpper()) = trimSpecialChars (serverFilter.ToUpper()) """ diff --git a/src/Fantomas.Tests/ComputationExpressionTests.fs b/src/Fantomas.Tests/ComputationExpressionTests.fs index 4bf5d01b61..ec396a52cb 100644 --- a/src/Fantomas.Tests/ComputationExpressionTests.fs +++ b/src/Fantomas.Tests/ComputationExpressionTests.fs @@ -94,8 +94,7 @@ let factors number = |> Seq.filter (fun x -> number % x = 0L)""" config |> prepend newline |> should equal """ -let factors number = - { 2L..number / 2L } |> Seq.filter (fun x -> number % x = 0L) +let factors number = { 2L..number / 2L } |> Seq.filter (fun x -> number % x = 0L) """ [] diff --git a/src/Fantomas.Tests/ControlStructureTests.fs b/src/Fantomas.Tests/ControlStructureTests.fs index cfc2628cb9..f26b5d6529 100644 --- a/src/Fantomas.Tests/ControlStructureTests.fs +++ b/src/Fantomas.Tests/ControlStructureTests.fs @@ -37,8 +37,7 @@ let test x y = else if x > y then "is greater than" else "Don't know" -if age < 10 then - printfn "You are only %d years old and already learning F#? Wow!" age +if age < 10 then printfn "You are only %d years old and already learning F#? Wow!" age """ [] diff --git a/src/Fantomas.Tests/DataStructureTests.fs b/src/Fantomas.Tests/DataStructureTests.fs index aee5d23575..bc3bf0bbb0 100644 --- a/src/Fantomas.Tests/DataStructureTests.fs +++ b/src/Fantomas.Tests/DataStructureTests.fs @@ -92,9 +92,7 @@ let vectorLength vec = | [| var1 |] -> var1 | [| var1; var2 |] -> sqrt (var1 * var1 + var2 * var2) | [| var1; var2; var3 |] -> sqrt (var1 * var1 + var2 * var2 + var3 * var3) - | _ -> - failwith "vectorLength called with an unsupported array size of %d." - (vec.Length) + | _ -> failwith "vectorLength called with an unsupported array size of %d." (vec.Length) """ [] diff --git a/src/Fantomas.Tests/FormattingSelectionOnlyTests.fs b/src/Fantomas.Tests/FormattingSelectionOnlyTests.fs index 2c11d4e100..e2f3c4643c 100644 --- a/src/Fantomas.Tests/FormattingSelectionOnlyTests.fs +++ b/src/Fantomas.Tests/FormattingSelectionOnlyTests.fs @@ -30,8 +30,7 @@ let rangeTest testValue mid size = let (var1, var2) as tuple1 = (1, 2)""" config |> append newline |> should equal """match testValue with - | var1 when var1 >= mid - size / 2 && var1 <= mid + size / 2 -> - printfn "The test value is in range." + | var1 when var1 >= mid - size / 2 && var1 <= mid + size / 2 -> printfn "The test value is in range." | _ -> printfn "The test value is out of range." """ diff --git a/src/Fantomas.Tests/FormattingSelectionTests.fs b/src/Fantomas.Tests/FormattingSelectionTests.fs index 0cd407b20b..5074d55b53 100644 --- a/src/Fantomas.Tests/FormattingSelectionTests.fs +++ b/src/Fantomas.Tests/FormattingSelectionTests.fs @@ -36,8 +36,7 @@ let (var1, var2) as tuple1 = (1, 2)""" config |> should equal """ let rangeTest testValue mid size = match testValue with - | var1 when var1 >= mid - size / 2 && var1 <= mid + size / 2 -> - printfn "The test value is in range." + | var1 when var1 >= mid - size / 2 && var1 <= mid + size / 2 -> printfn "The test value is in range." | _ -> printfn "The test value is out of range." let (var1, var2) as tuple1 = (1, 2)""" diff --git a/src/Fantomas.Tests/FunctionDefinitionTests.fs b/src/Fantomas.Tests/FunctionDefinitionTests.fs index eed2189f85..9f1604485f 100644 --- a/src/Fantomas.Tests/FunctionDefinitionTests.fs +++ b/src/Fantomas.Tests/FunctionDefinitionTests.fs @@ -127,10 +127,8 @@ let inline heterogenousAdd(value1 : ^T when (^T or ^U) : (static member (+) : ^T value1 + value2""" config |> prepend newline |> should equal """ -let inline add (value1: ^T when ^T: (static member (+): ^T * ^T -> ^T), - value2: ^T) = value1 + value2 -let inline heterogenousAdd (value1: ^T when (^T or ^U): (static member (+): ^T * ^U - -> ^T), value2: ^U) = +let inline add (value1: ^T when ^T: (static member (+): ^T * ^T -> ^T), value2: ^T) = value1 + value2 +let inline heterogenousAdd (value1: ^T when (^T or ^U): (static member (+): ^T * ^U -> ^T), value2: ^U) = value1 + value2 """ diff --git a/src/Fantomas.Tests/NoTrailingSpacesTests.fs b/src/Fantomas.Tests/NoTrailingSpacesTests.fs index 073a8755c8..75c9c98c37 100644 --- a/src/Fantomas.Tests/NoTrailingSpacesTests.fs +++ b/src/Fantomas.Tests/NoTrailingSpacesTests.fs @@ -15,6 +15,5 @@ let ``should not confuse me with an extra space at end of line v2``() = formatSourceString false codeSnippet config |> should equal """let ``should not extrude without positive distance``() = let args = [| "-i"; "input.dxf"; "-o"; "output.pdf"; "--op"; "extrude" |] - (fun () -> parseCmdLine args |> ignore) - |> should throw typeof + (fun () -> parseCmdLine args |> ignore) |> should throw typeof """ \ No newline at end of file diff --git a/src/Fantomas.Tests/OperatorTests.fs b/src/Fantomas.Tests/OperatorTests.fs index c7451d6e01..b8cf52f8f7 100644 --- a/src/Fantomas.Tests/OperatorTests.fs +++ b/src/Fantomas.Tests/OperatorTests.fs @@ -91,7 +91,7 @@ let ``should pattern match on quotation expression``() = let ``should break on . operator``() = formatSourceString false """pattern.Replace(".", @"\.").Replace("$", @"\$").Replace("^", @"\^").Replace("{", @"\{").Replace("[", @"\[").Replace("(", @"\(").Replace(")", @"\)").Replace("+", @"\+") - """ config + """ { config with PageWidth = 80 } |> prepend newline |> should equal """ pattern.Replace(".", @"\.").Replace("$", @"\$").Replace("^", @"\^") @@ -106,7 +106,7 @@ let ``should break on . operator and keep indentation``() = (x + y) .Replace(seperator + "**" + seperator, replacementSeparator + "(.|?" + replacementSeparator + ")?" ) .Replace("**" + seperator, ".|(?<=^|" + replacementSeparator + ")" ) - """ config + """ { config with PageWidth = 80 } |> should equal """let pattern = (x + y) .Replace(seperator + "**" + seperator, diff --git a/src/Fantomas.Tests/PatternMatchingTests.fs b/src/Fantomas.Tests/PatternMatchingTests.fs index 45922df564..84b52edc11 100644 --- a/src/Fantomas.Tests/PatternMatchingTests.fs +++ b/src/Fantomas.Tests/PatternMatchingTests.fs @@ -51,8 +51,7 @@ printfn "%d %d %A" var1 var2 tuple1""" config |> should equal """ let rangeTest testValue mid size = match testValue with - | var1 when var1 >= mid - size / 2 && var1 <= mid + size / 2 -> - printfn "The test value is in range." + | var1 when var1 >= mid - size / 2 && var1 <= mid + size / 2 -> printfn "The test value is in range." | _ -> printfn "The test value is out of range." let (var1, var2) as tuple1 = (1, 2) @@ -197,7 +196,7 @@ try fst(find (fun (s, (s', ty): int * int) -> s' = s0 && can (type_match ty ty0) []) (!the_interface)) with -| Failure _ -> s0""" config +| Failure _ -> s0""" { config with PageWidth = 80 } |> prepend newline |> should equal """ try @@ -215,8 +214,7 @@ find (fun (Ident op) x y -> Combp(Combp(Varp(op,dpty),x),y)) "term after binary """ config |> prepend newline |> should equal """ -find (fun (Ident op) x y -> Combp(Combp(Varp(op, dpty), x), y)) - "term after binary operator" inp +find (fun (Ident op) x y -> Combp(Combp(Varp(op, dpty), x), y)) "term after binary operator" inp """ [] @@ -380,8 +378,7 @@ let (|OneLinerBinding|MultilineBinding|) b = | DoBinding([], PreXmlDoc [||], OneLinerExpr _) | MemberBinding([], PreXmlDoc [||], _, _, _, _, OneLinerExpr _) | PropertyBinding([], PreXmlDoc [||], _, _, _, _, OneLinerExpr _) - | ExplicitCtor([], PreXmlDoc [||], _, _, OneLinerExpr _, _) -> - OneLinerBinding b + | ExplicitCtor([], PreXmlDoc [||], _, _, OneLinerExpr _, _) -> OneLinerBinding b | _ -> MultilineBinding b """ diff --git a/src/Fantomas.Tests/PipingTests.fs b/src/Fantomas.Tests/PipingTests.fs index 5c032bd351..f33e828680 100644 --- a/src/Fantomas.Tests/PipingTests.fs +++ b/src/Fantomas.Tests/PipingTests.fs @@ -13,7 +13,7 @@ let f x = <|> if someveryveryveryverylongexpression then someveryveryveryverylongexpression else someveryveryveryverylongexpression <|> if someveryveryveryverylongexpression then someveryveryveryverylongexpression else someveryveryveryverylongexpression |> f - """ config + """ { config with PageWidth = 80 } |> prepend newline |> should equal """ let f x = diff --git a/src/Fantomas.Tests/QuotationTests.fs b/src/Fantomas.Tests/QuotationTests.fs index 1f58838c5c..d51843a95b 100644 --- a/src/Fantomas.Tests/QuotationTests.fs +++ b/src/Fantomas.Tests/QuotationTests.fs @@ -25,11 +25,6 @@ let ``untyped quotations``() = [] let ``should preserve unit literal``() = - formatSourceString false """ - let logger = Mock().Setup(fun log -> <@ log.Log(error) @>).Returns(()).Create() - """ config - |> prepend newline - |> should equal """ -let logger = - Mock().Setup(fun log -> <@ log.Log(error) @>).Returns(()).Create() -""" \ No newline at end of file + shouldNotChangeAfterFormat """ +let logger = Mock().Setup(fun log -> <@ log.Log(error) @>).Returns(()).Create() +""" diff --git a/src/Fantomas.Tests/RecordTests.fs b/src/Fantomas.Tests/RecordTests.fs index 434b2d5b4f..67af13aea5 100644 --- a/src/Fantomas.Tests/RecordTests.fs +++ b/src/Fantomas.Tests/RecordTests.fs @@ -82,8 +82,7 @@ type Element = /// Replaces the children. static member (-): self:Element * children:#seq<#INode> -> Element /// Replaces the attributes. - static member WithAttributes: attrs:#seq - -> self:Element -> Element + static member WithAttributes: attrs:#seq -> self:Element -> Element /// Replaces the attributes. static member (+): self:Element * attrs:#seq -> Element /// Replaces the children with a single text node. @@ -194,22 +193,12 @@ type rate2 = Rate of float [] let ``should keep comments on records``() = - formatSourceString false """ + shouldNotChangeAfterFormat """ let newDocument = //somecomment { program = Encoding.Default.GetBytes(document.Program) |> Encoding.UTF8.GetString content = Encoding.Default.GetBytes(document.Content) |> Encoding.UTF8.GetString created = document.Created.ToLocalTime() } |> JsonConvert.SerializeObject -""" config - |> prepend newline - |> should equal """ -let newDocument = //somecomment - { program = - Encoding.Default.GetBytes(document.Program) |> Encoding.UTF8.GetString - content = - Encoding.Default.GetBytes(document.Content) |> Encoding.UTF8.GetString - created = document.Created.ToLocalTime() } - |> JsonConvert.SerializeObject """ [] diff --git a/src/Fantomas.Tests/SignatureTests.fs b/src/Fantomas.Tests/SignatureTests.fs index c92ee825ef..8720509173 100644 --- a/src/Fantomas.Tests/SignatureTests.fs +++ b/src/Fantomas.Tests/SignatureTests.fs @@ -27,25 +27,20 @@ let ``should keep the (string * string) list type signature in records``() = [] let ``should keep the (string * string) list type signature in functions``() = - formatSourceString false """let MSBuildWithProjectProperties outputPath (targets : string) - (properties : string -> (string * string) list) projects = doingsomstuff - - """ config - |> should equal """let MSBuildWithProjectProperties outputPath (targets: string) - (properties: string -> (string * string) list) projects = doingsomstuff + shouldNotChangeAfterFormat """ +let MSBuildWithProjectProperties outputPath (targets: string) (properties: string -> (string * string) list) projects = + doingsomstuff """ [] let ``should keep the string * string list type signature in functions``() = - formatSourceString false """let MSBuildWithProjectProperties outputPath (targets : string) - (properties : (string -> string) * string list) projects = doingsomstuff - - """ config - |> should equal """let MSBuildWithProjectProperties outputPath (targets: string) - (properties: (string -> string) * string list) projects = doingsomstuff + shouldNotChangeAfterFormat """ +let MSBuildWithProjectProperties outputPath (targets: string) (properties: (string -> string) * string list) projects = + doingsomstuff """ + [] let ``should not add parens in signature``() = formatSourceString false """type Route = diff --git a/src/Fantomas.Tests/TypeDeclarationTests.fs b/src/Fantomas.Tests/TypeDeclarationTests.fs index 6b932b563c..1aff763ed2 100644 --- a/src/Fantomas.Tests/TypeDeclarationTests.fs +++ b/src/Fantomas.Tests/TypeDeclarationTests.fs @@ -543,8 +543,7 @@ let ``should keep the ? in optional parameters``() = """ config |> should equal """type Shell() = static member private GetParams(cmd, ?args) = doStuff - static member Exec(cmd, ?args) = - shellExec (Shell.GetParams(cmd, ?args = args)) + static member Exec(cmd, ?args) = shellExec (Shell.GetParams(cmd, ?args = args)) """ [] @@ -612,14 +611,10 @@ type BlobHelper(Account: CloudStorageAccount) = new(configurationSettingName, hostedService) = CloudStorageAccount.SetConfigurationSettingPublisher(fun configName configSettingPublisher -> let connectionString = - if hostedService then - RoleEnvironment.GetConfigurationSettingValue(configName) - else - ConfigurationManager.ConnectionStrings.[configName].ConnectionString + if hostedService then RoleEnvironment.GetConfigurationSettingValue(configName) + else ConfigurationManager.ConnectionStrings.[configName].ConnectionString configSettingPublisher.Invoke(connectionString) |> ignore) - BlobHelper - (CloudStorageAccount.FromConfigurationSetting - (configurationSettingName)) + BlobHelper(CloudStorageAccount.FromConfigurationSetting(configurationSettingName)) """ [] diff --git a/src/Fantomas.Tests/UnionTests.fs b/src/Fantomas.Tests/UnionTests.fs index e5c38c4474..39aedac649 100644 --- a/src/Fantomas.Tests/UnionTests.fs +++ b/src/Fantomas.Tests/UnionTests.fs @@ -28,21 +28,13 @@ type X = [] let ``enums conversion``() = - formatSourceString false """ -type uColor = - | Red = 0u - | Green = 1u - | Blue = 2u -let col3 = Microsoft.FSharp.Core.LanguagePrimitives.EnumOfValue(2u)""" config - |> prepend newline - |> should equal """ + shouldNotChangeAfterFormat """ type uColor = | Red = 0u | Green = 1u | Blue = 2u -let col3 = - Microsoft.FSharp.Core.LanguagePrimitives.EnumOfValue(2u) +let col3 = Microsoft.FSharp.Core.LanguagePrimitives.EnumOfValue(2u) """ [] @@ -149,8 +141,7 @@ type uColor = | Green = 1u | Blue = 2u -let col3 = - Microsoft.FSharp.Core.LanguagePrimitives.EnumOfValue(2u) +let col3 = Microsoft.FSharp.Core.LanguagePrimitives.EnumOfValue(2u) """ [] diff --git a/src/Fantomas/FormatConfig.fs b/src/Fantomas/FormatConfig.fs index d208090f4d..391c136ad5 100644 --- a/src/Fantomas/FormatConfig.fs +++ b/src/Fantomas/FormatConfig.fs @@ -27,7 +27,7 @@ type FormatConfig = static member Default = { IndentSpaceNum = 4 - PageWidth = 80 + PageWidth = 120 PreserveEndOfLine = false SemicolonAtEndOfLine = false SpaceBeforeArgument = true