File tree Expand file tree Collapse file tree 5 files changed +216
-78
lines changed
Expand file tree Collapse file tree 5 files changed +216
-78
lines changed Original file line number Diff line number Diff line change @@ -661,7 +661,7 @@ type TestType =
661661 {
662662 Foo : int
663663 }
664- """ config
664+ """ { config with MaxRecordWidth = 10 }
665665 |> prepend newline
666666 |> should equal """
667667type TestType =
@@ -720,3 +720,54 @@ let person =
720720 Address = { Street = "Bakerstreet" ; Number = 42 } // end address
721721 } // end person
722722"""
723+
724+ [<Test>]
725+ let ``line comments before access modifier of multiline record type`` () =
726+ formatSourceString true """
727+ namespace Foo
728+
729+ type TestType =
730+ // Here is some comment about the type
731+ // Some more comments
732+ private
733+ {
734+ Foo : int
735+ Barry: string
736+ }
737+ """ { config with MaxRecordWidth = 10 }
738+ |> prepend newline
739+ |> should equal """
740+ namespace Foo
741+
742+ type TestType =
743+ // Here is some comment about the type
744+ // Some more comments
745+ private
746+ {
747+ Foo : int
748+ Barry : string
749+ }
750+ """
751+
752+ [<Test>]
753+ let ``line comments before access modifier of single line record type`` () =
754+ formatSourceString true """
755+ namespace Foo
756+
757+ type TestType =
758+ // Here is some comment about the type
759+ // Some more comments
760+ private
761+ {
762+ Meh : TimeSpan
763+ }
764+ """ config
765+ |> prepend newline
766+ |> should equal """
767+ namespace Foo
768+
769+ type TestType =
770+ // Here is some comment about the type
771+ // Some more comments
772+ private { Meh : TimeSpan }
773+ """
Original file line number Diff line number Diff line change @@ -492,8 +492,6 @@ type ShortExpressionInfo =
492492 member x.Foo() = ()
493493"""
494494
495- // FIXME: See https://github.com/fsprojects/fantomas/issues/1171
496- [<Ignore( " Issue #1171" ) >]
497495[<Test>]
498496let ``internal keyword before multiline record type , 1171`` () =
499497 formatSourceString false """
@@ -506,8 +504,6 @@ type A =
506504 YetAnotherLongIdentifier: bool }
507505"""
508506
509- // FIXME: See https://github.com/fsprojects/fantomas/issues/1171
510- [<Ignore( " Issue #1171" ) >]
511507[<Test>]
512508let ``internal keyword before multiline record type in signature file , 1171`` () =
513509 formatSourceString true """ namespace Bar
Original file line number Diff line number Diff line change @@ -586,8 +586,9 @@ let ``internal keyword before long record type`` () =
586586namespace Bar
587587
588588type A =
589- internal { ALongIdentifier: string
590- YetAnotherLongIdentifier: bool }
589+ internal
590+ { ALongIdentifier: string
591+ YetAnotherLongIdentifier: bool }
591592"""
592593
593594[<Test>]
@@ -849,3 +850,52 @@ type t1 = bool
849850[<SomeAttribute>]
850851type t2 = bool
851852"""
853+
854+ [<Test>]
855+ let ``line comments before access modifier of multiline record type`` () =
856+ formatSourceString true """
857+ namespace Foo
858+
859+ type TestType =
860+ // Here is some comment about the type
861+ // Some more comments
862+ private
863+ {
864+ Foo : int
865+ Barry: string
866+ }
867+ """ { config with MaxRecordWidth = 10 }
868+ |> prepend newline
869+ |> should equal """
870+ namespace Foo
871+
872+ type TestType =
873+ // Here is some comment about the type
874+ // Some more comments
875+ private
876+ { Foo: int
877+ Barry: string }
878+ """
879+
880+ [<Test>]
881+ let ``line comments before access modifier of single line record type`` () =
882+ formatSourceString true """
883+ namespace Foo
884+
885+ type TestType =
886+ // Here is some comment about the type
887+ // Some more comments
888+ private
889+ {
890+ Meh : TimeSpan
891+ }
892+ """ config
893+ |> prepend newline
894+ |> should equal """
895+ namespace Foo
896+
897+ type TestType =
898+ // Here is some comment about the type
899+ // Some more comments
900+ private { Meh: TimeSpan }
901+ """
Original file line number Diff line number Diff line change @@ -1527,6 +1527,30 @@ type TestType =
15271527 private { Foo: int }
15281528"""
15291529
1530+ [<Test>]
1531+ let ``comments before access modifier and multiline record type`` () =
1532+ formatSourceString false """
1533+ type OlapCube =
1534+ // Here is some comment about the type
1535+ // Some more comments
1536+ private
1537+ {
1538+ OneDimension : int
1539+ TwoDimension : int
1540+ ThreeDimension : int
1541+ }
1542+ """ config
1543+ |> prepend newline
1544+ |> should equal """
1545+ type OlapCube =
1546+ // Here is some comment about the type
1547+ // Some more comments
1548+ private
1549+ { OneDimension: int
1550+ TwoDimension: int
1551+ ThreeDimension: int }
1552+ """
1553+
15301554[<Test>]
15311555let ``alternative long member definition`` () =
15321556 formatSourceString false """
@@ -1805,3 +1829,21 @@ let ``union type with constraint`` () =
18051829 formatSourceString false """ type 'a t when 'a :> IDisposable = T of 'a option""" config
18061830 |> should equal """ type 'a t when 'a :> IDisposable = T of 'a option
18071831"""
1832+
1833+ [<Test>]
1834+ let ``add newline and indent for multiline internal record definition , 658`` () =
1835+ formatSourceString false """
1836+ type RequestParser<'ctx, 'a> = internal {
1837+ consumedFields: Set<ConsumedFieldName>
1838+ parse: 'ctx -> Request -> Async<Result<'a, Error list>>
1839+ prohibited: ProhibitedRequestGetter list
1840+ }
1841+ """ config
1842+ |> prepend newline
1843+ |> should equal """
1844+ type RequestParser<'ctx, 'a> =
1845+ internal
1846+ { consumedFields: Set<ConsumedFieldName>
1847+ parse: 'ctx -> Request -> Async<Result<'a, Error list>>
1848+ prohibited: ProhibitedRequestGetter list }
1849+ """
You can’t perform that action at this time.
0 commit comments