From e8a801bc867a90760bffa32de607c346274b1703 Mon Sep 17 00:00:00 2001 From: nojaf Date: Fri, 4 Mar 2022 14:35:24 +0100 Subject: [PATCH] Add regression tests for lost comments after equals sign. --- CHANGELOG.md | 6 ++++++ src/Fantomas.Tests/RecordTests.fs | 19 +++++++++++++++++++ src/Fantomas.Tests/TypeDeclarationTests.fs | 21 +++++++++++++++++++++ 3 files changed, 46 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c31c9258a..c48c15f7f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [Unreleased] + +### Fixed +* Comment after equals is remove in anonymous record. [#1921](https://github.com/fsprojects/fantomas/issues/1921) +* Comment after equals in record type is lost. [#2001](https://github.com/fsprojects/fantomas/issues/2001) + ## [4.7.0] - 2022-03-04 ### Changed diff --git a/src/Fantomas.Tests/RecordTests.fs b/src/Fantomas.Tests/RecordTests.fs index e625d8e279..f3bb07693a 100644 --- a/src/Fantomas.Tests/RecordTests.fs +++ b/src/Fantomas.Tests/RecordTests.fs @@ -2001,3 +2001,22 @@ type Foo = // comment type Foo = // comment { Bar: int } """ + +[] +let ``comment after equals sign in anonymous record field, 1921`` () = + formatSourceString + false + """ +let a = + {| Foo = // + 2 |} +""" + config + |> prepend newline + |> should + equal + """ +let a = + {| Foo = // + 2 |} +""" diff --git a/src/Fantomas.Tests/TypeDeclarationTests.fs b/src/Fantomas.Tests/TypeDeclarationTests.fs index 64ac340d72..41a010aa3e 100644 --- a/src/Fantomas.Tests/TypeDeclarationTests.fs +++ b/src/Fantomas.Tests/TypeDeclarationTests.fs @@ -2962,3 +2962,24 @@ type Graph<'a when 'a:comparison> = Set<'a * 'a> """ type Graph<'a when 'a: comparison> = Set<'a * 'a> """ + +[] +let ``comment after equals sign in type defn, 2001`` () = + formatSourceString + false + """ +type V = // comment + { X: SomeFieldType + Y: OhSomethingElse + Z: ALongTypeName } +""" + config + |> prepend newline + |> should + equal + """ +type V = // comment + { X: SomeFieldType + Y: OhSomethingElse + Z: ALongTypeName } +"""