Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ type TestType =
{
Foo : int
}
""" config
""" { config with MaxRecordWidth = 10 }
|> prepend newline
|> should equal """
type TestType =
Expand Down Expand Up @@ -720,3 +720,54 @@ let person =
Address = { Street = "Bakerstreet" ; Number = 42 } // end address
} // end person
"""

[<Test>]
let ``line comments before access modifier of multiline record type`` () =
formatSourceString true """
namespace Foo

type TestType =
// Here is some comment about the type
// Some more comments
private
{
Foo : int
Barry: string
}
""" { config with MaxRecordWidth = 10 }
|> prepend newline
|> should equal """
namespace Foo

type TestType =
// Here is some comment about the type
// Some more comments
private
{
Foo : int
Barry : string
}
"""

[<Test>]
let ``line comments before access modifier of single line record type`` () =
formatSourceString true """
namespace Foo

type TestType =
// Here is some comment about the type
// Some more comments
private
{
Meh : TimeSpan
}
""" config
|> prepend newline
|> should equal """
namespace Foo

type TestType =
// Here is some comment about the type
// Some more comments
private { Meh : TimeSpan }
"""
4 changes: 0 additions & 4 deletions src/Fantomas.Tests/NumberOfItemsRecordTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -492,8 +492,6 @@ type ShortExpressionInfo =
member x.Foo() = ()
"""

// FIXME: See https://github.com/fsprojects/fantomas/issues/1171
[<Ignore("Issue #1171")>]
[<Test>]
let ``internal keyword before multiline record type, 1171`` () =
formatSourceString false """
Expand All @@ -506,8 +504,6 @@ type A =
YetAnotherLongIdentifier: bool }
"""

// FIXME: See https://github.com/fsprojects/fantomas/issues/1171
[<Ignore("Issue #1171")>]
[<Test>]
let ``internal keyword before multiline record type in signature file, 1171`` () =
formatSourceString true """namespace Bar
Expand Down
54 changes: 52 additions & 2 deletions src/Fantomas.Tests/SignatureTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -586,8 +586,9 @@ let ``internal keyword before long record type`` () =
namespace Bar

type A =
internal { ALongIdentifier: string
YetAnotherLongIdentifier: bool }
internal
{ ALongIdentifier: string
YetAnotherLongIdentifier: bool }
"""

[<Test>]
Expand Down Expand Up @@ -849,3 +850,52 @@ type t1 = bool
[<SomeAttribute>]
type t2 = bool
"""

[<Test>]
let ``line comments before access modifier of multiline record type`` () =
formatSourceString true """
namespace Foo

type TestType =
// Here is some comment about the type
// Some more comments
private
{
Foo : int
Barry: string
}
""" { config with MaxRecordWidth = 10 }
|> prepend newline
|> should equal """
namespace Foo

type TestType =
// Here is some comment about the type
// Some more comments
private
{ Foo: int
Barry: string }
"""

[<Test>]
let ``line comments before access modifier of single line record type`` () =
formatSourceString true """
namespace Foo

type TestType =
// Here is some comment about the type
// Some more comments
private
{
Meh : TimeSpan
}
""" config
|> prepend newline
|> should equal """
namespace Foo

type TestType =
// Here is some comment about the type
// Some more comments
private { Meh: TimeSpan }
"""
42 changes: 42 additions & 0 deletions src/Fantomas.Tests/TypeDeclarationTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1527,6 +1527,30 @@ type TestType =
private { Foo: int }
"""

[<Test>]
let ``comments before access modifier and multiline record type`` () =
formatSourceString false """
type OlapCube =
// Here is some comment about the type
// Some more comments
private
{
OneDimension : int
TwoDimension : int
ThreeDimension : int
}
""" config
|> prepend newline
|> should equal """
type OlapCube =
// Here is some comment about the type
// Some more comments
private
{ OneDimension: int
TwoDimension: int
ThreeDimension: int }
"""

[<Test>]
let ``alternative long member definition`` () =
formatSourceString false """
Expand Down Expand Up @@ -1805,3 +1829,21 @@ let ``union type with constraint`` () =
formatSourceString false """type 'a t when 'a :> IDisposable = T of 'a option""" config
|> should equal """type 'a t when 'a :> IDisposable = T of 'a option
"""

[<Test>]
let ``add newline and indent for multiline internal record definition, 658`` () =
formatSourceString false """
type RequestParser<'ctx, 'a> = internal {
consumedFields: Set<ConsumedFieldName>
parse: 'ctx -> Request -> Async<Result<'a, Error list>>
prohibited: ProhibitedRequestGetter list
}
""" config
|> prepend newline
|> should equal """
type RequestParser<'ctx, 'a> =
internal
{ consumedFields: Set<ConsumedFieldName>
parse: 'ctx -> Request -> Async<Result<'a, Error list>>
prohibited: ProhibitedRequestGetter list }
"""
Loading