Skip to content

Commit

Permalink
fix default spacing for val and member (#1935)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsyme committed Oct 31, 2021
1 parent 95833f5 commit 420ef5c
Show file tree
Hide file tree
Showing 13 changed files with 146 additions and 143 deletions.
62 changes: 31 additions & 31 deletions src/Fantomas.Tests/ClassTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ module Heap
type Heap<'T when 'T: comparison> =
class
new : capacity: int -> Heap<'T>
member Clear : unit -> unit
member ExtractMin : unit -> 'T
member Insert : k: 'T -> unit
member IsEmpty : unit -> bool
member PeekMin : unit -> 'T
override ToString : unit -> string
member Count : int
new: capacity: int -> Heap<'T>
member Clear: unit -> unit
member ExtractMin: unit -> 'T
member Insert: k: 'T -> unit
member IsEmpty: unit -> bool
member PeekMin: unit -> 'T
override ToString: unit -> string
member Count: int
end
"""

Expand All @@ -65,19 +65,19 @@ type Class7<'T when 'T : (new : unit -> 'T)>() =
|> should
equal
"""
type Class4<'T when 'T: (static member staticMethod1 : unit -> 'T)> =
type Class4<'T when 'T: (static member staticMethod1: unit -> 'T)> =
class
end
type Class5<'T when 'T: (member Method1 : 'T -> int)> =
type Class5<'T when 'T: (member Method1: 'T -> int)> =
class
end
type Class6<'T when 'T: (member Property1 : int)> =
type Class6<'T when 'T: (member Property1: int)> =
class
end
type Class7<'T when 'T: (new : unit -> 'T)>() =
type Class7<'T when 'T: (new: unit -> 'T)>() =
member val Field = new 'T()
"""

Expand Down Expand Up @@ -124,15 +124,15 @@ type Shape2D(x0: float, y0: float) =
with get () = y
and set yval = y <- yval
abstract Area : float
abstract Perimeter : float
abstract Name : string
abstract Area: float
abstract Perimeter: float
abstract Name: string
member this.Move dx dy =
x <- x + dx
y <- y + dy
abstract member Rotate : float -> unit
abstract member Rotate: float -> unit
default this.Rotate(angle) = rotAngle <- rotAngle + angle
"""

Expand All @@ -156,13 +156,13 @@ type A =
equal
"""
type A =
abstract B : ?p1: (float * int) -> unit
abstract C : ?p1: float * int -> unit
abstract D : ?p1: (int -> int) -> unit
abstract E : ?p1: float -> unit
abstract F : ?p1: float * ?p2: float -> unit
abstract G : p1: float * ?p2: float -> unit
abstract H : float * ?p2: float -> unit
abstract B: ?p1: (float * int) -> unit
abstract C: ?p1: float * int -> unit
abstract D: ?p1: (int -> int) -> unit
abstract E: ?p1: float -> unit
abstract F: ?p1: float * ?p2: float -> unit
abstract G: p1: float * ?p2: float -> unit
abstract H: float * ?p2: float -> unit
"""

[<Test>]
Expand Down Expand Up @@ -615,9 +615,9 @@ let ``no extra new line before abstract member with attribute, 586`` () =
type A =
[<EmitConstructor>]
abstract Create : Unit -> A
abstract Create: Unit -> A
abstract b : Unit -> Unit
abstract b: Unit -> Unit
"""

[<Test>]
Expand All @@ -627,10 +627,10 @@ let ``no extra new line between abstract members with attribute, 586`` () =
type A =
[<Emit("a")>]
abstract a : Unit -> string
abstract a: Unit -> string
[<Emit("b")>]
abstract b : Unit -> string
abstract b: Unit -> string
"""

[<Test>]
Expand Down Expand Up @@ -780,7 +780,7 @@ type Foo =
module Example
type Foo =
abstract member bar : int
abstract member bar: int
"""

[<Test>]
Expand Down Expand Up @@ -830,9 +830,9 @@ type ISingleExpressionValue<'p, 'o, 'v when 'p :> IProperty and 'o :> IOperator
"""
type ISingleExpressionValue<'p, 'o, 'v when 'p :> IProperty and 'o :> IOperator and 'p: equality and 'o: equality and 'v: equality>
() =
abstract Property : 'p
abstract Operator : 'o
abstract Value : 'v
abstract Property: 'p
abstract Operator: 'o
abstract Value: 'v
"""

[<Test>]
Expand Down
10 changes: 5 additions & 5 deletions src/Fantomas.Tests/CommentTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1070,12 +1070,12 @@ type IExports =
"""
[<AllowNullLiteral>]
type IExports =
abstract DataSet : DataSetStatic
abstract DataView : DataViewStatic
abstract Graph2d : Graph2dStatic
abstract Timeline : TimelineStatic
abstract DataSet: DataSetStatic
abstract DataView: DataViewStatic
abstract Graph2d: Graph2dStatic
abstract Timeline: TimelineStatic
// abstract Timeline: TimelineStaticStatic
abstract Network : NetworkStatic
abstract Network: NetworkStatic

// type [<AllowNullLiteral>] MomentConstructor1 =
// [<Emit "$0($1...)">] abstract Invoke: ?inp: MomentInput * ?format: MomentFormatSpecification * ?strict: bool -> Moment
Expand Down
6 changes: 3 additions & 3 deletions src/Fantomas.Tests/FormatAstTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ type Foo =
equal
"""[<AbstractClass>]
type Foo =
abstract foo : int
abstract foo: int
override __.foo = 1"""

[<Test>]
Expand All @@ -107,7 +107,7 @@ type Foo =
equal
"""[<AbstractClass>]
type Foo =
abstract foo : int
abstract foo: int
default __.foo = 1"""

[<Test>]
Expand All @@ -123,7 +123,7 @@ type Foo =
equal
"""[<AbstractClass>]
type Foo =
abstract foo : int
abstract foo: int
override __.foo = 1"""

[<Test>]
Expand Down
12 changes: 6 additions & 6 deletions src/Fantomas.Tests/FunctionDefinitionTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,9 @@ let inline heterogenousAdd(value1 : ^T when (^T or ^U) : (static member (+) : ^T
|> should
equal
"""
let inline add (value1: ^T when ^T: (static member (+) : ^T * ^T -> ^T), value2: ^T) = value1 + value2
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 heterogenousAdd (value1: ^T when (^T or ^U): (static member (+): ^T * ^U -> ^T), value2: ^U) =
value1 + value2
"""

Expand Down Expand Up @@ -448,8 +448,8 @@ let inline implicit< ^a,^b when ^a : (static member op_Implicit : ^b -> ^a)> arg
|> should
equal
"""
let inline implicit< ^a, ^b when ^a: (static member op_Implicit : ^b -> ^a)> arg =
(^a: (static member op_Implicit : ^b -> ^a) arg)
let inline implicit< ^a, ^b when ^a: (static member op_Implicit: ^b -> ^a)> arg =
(^a: (static member op_Implicit: ^b -> ^a) arg)
"""

[<Test>]
Expand Down Expand Up @@ -491,7 +491,7 @@ let ``don't create redundant parentheses outside trait calls`` () =
|> should
equal
"""
let f (arg: 'T) = (^T: (member Value : string) arg)
let f (arg: 'T) = (^T: (member Value: string) arg)
"""

[<Test>]
Expand Down Expand Up @@ -934,7 +934,7 @@ let inline deserialize< ^a when ( ^a or FromJsonDefaults) : (static member FromJ
|> should
equal
"""
let inline deserialize< ^a when ^a: (static member FromJson : ^a -> Json< ^a >)> json =
let inline deserialize< ^a when ^a: (static member FromJson: ^a -> Json< ^a >)> json =
json |> Json.parse |> Json.deserialize< ^a>
"""

Expand Down
24 changes: 12 additions & 12 deletions src/Fantomas.Tests/InterfaceTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type Interface3 =
equal
"""
type IPrintable =
abstract member Print : unit -> unit
abstract member Print: unit -> unit
type SomeClass1(x: int, y: float) =
interface IPrintable with
Expand All @@ -35,7 +35,7 @@ type SomeClass1(x: int, y: float) =
type Interface3 =
inherit Interface1
inherit Interface2
abstract member Method3 : int -> int
abstract member Method3: int -> int
"""

[<Test>]
Expand Down Expand Up @@ -135,7 +135,7 @@ let ``should keep named arguments on abstract members`` () =
|> should
equal
"""type IThing =
abstract Foo : name: string * age: int -> bool
abstract Foo: name: string * age: int -> bool
"""

[<Test>]
Expand All @@ -149,7 +149,7 @@ let ``should not skip 'with get()' in indexers`` () =
|> should
equal
"""type Interface =
abstract Item : int -> char with get
abstract Item: int -> char with get
"""

[<Test>]
Expand Down Expand Up @@ -202,10 +202,10 @@ type MyLogInteface() =
equal
"""
type LogInterface =
abstract member Print : string -> unit
abstract member GetLogFile : string -> string
abstract member Info : unit -> unit
abstract member Version : unit -> unit
abstract member Print: string -> unit
abstract member GetLogFile: string -> string
abstract member Info: unit -> unit
abstract member Version: unit -> unit
type MyLogInteface() =
interface LogInterface with
Expand Down Expand Up @@ -234,7 +234,7 @@ type IArgParserTemplate =
"""/// Interface that must be implemented by all Argu template types
type IArgParserTemplate =
/// returns a usage string for every union case
abstract Usage : string
abstract Usage: string
"""

[<Test>]
Expand Down Expand Up @@ -273,7 +273,7 @@ type Test =
equal
"""
type Test =
abstract RunJobs :
abstract RunJobs:
folder: string
* ?jobs: string
* ?ctm: string
Expand Down Expand Up @@ -319,8 +319,8 @@ type IMyInterface =
equal
"""
type IMyInterface =
abstract MyProp : bool with get, set
abstract MyMethod : unit -> unit
abstract MyProp: bool with get, set
abstract MyMethod: unit -> unit
"""

[<Test>]
Expand Down
16 changes: 8 additions & 8 deletions src/Fantomas.Tests/ModuleTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,15 @@ end"""
"""
module Utils
val turnTracingOn : unit -> unit
val turnTracingOff : unit -> unit
val isTraced : unit -> bool
val turnTracingOn: unit -> unit
val turnTracingOff: unit -> unit
val isTraced: unit -> bool
module Random =
val exponential : mean: float -> float
val nextInt : max: int -> int
val nextInt64 : max: int64 -> int64
val next : max: float -> float
val exponential: mean: float -> float
val nextInt: max: int -> int
val nextInt64: max: int64 -> int64
val next: max: float -> float
"""

[<Test>]
Expand Down Expand Up @@ -703,7 +703,7 @@ namespace Test
module App =
type Msg = B of C
val a : string
val a: string
"""

[<Test>]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ type Range =
To: float
Name: string }
member Length : unit -> int
member Length: unit -> int
"""

[<Test>]
Expand All @@ -211,7 +211,7 @@ type Color =
| Green
| Blue
member ToInt : unit -> int
member ToInt: unit -> int
"""

[<Test>]
Expand All @@ -237,7 +237,7 @@ type Color =
| Green = 1
| Blue = 2
member ToInt : unit -> int
member ToInt: unit -> int
"""

[<Test>]
Expand All @@ -257,7 +257,7 @@ namespace Signature
type HttpContext with
member QueryString : unit -> string
member QueryString: unit -> string
"""

[<Test>]
Expand Down Expand Up @@ -306,7 +306,7 @@ type MyRecord =
Street: string
Number: int }
member Score : unit -> int
member Score: unit -> int
type MyRecord =
{ SomeField: int }
Expand All @@ -318,7 +318,7 @@ type Color =
| Green = 1
| Blue = 2
member ToInt : unit -> int
member ToInt: unit -> int
"""

[<Test>]
Expand Down
2 changes: 1 addition & 1 deletion src/Fantomas.Tests/NumberOfItemsRecordTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ type MyRecord =
Bar: string
Street: string
Number: int }
member Score : unit -> int
member Score: unit -> int
"""


Expand Down
Loading

0 comments on commit 420ef5c

Please sign in to comment.