Skip to content
Closed
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
34 changes: 34 additions & 0 deletions src/Fantomas.Core.Tests/AutoPropertiesTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,40 @@ open NUnit.Framework
open FsUnit
open Fantomas.Core.Tests.TestHelpers

[<Test>]
let ``auto-property with attribute`` () =
formatSourceString
"""
type X() =
[<DefaultValue>]
member val Y: int = 0 with get, set
"""
config
|> prepend newline
|> should
equal
"""
type X() =
[<DefaultValue>]
member val Y: int = 0 with get, set
"""

[<Test>]
let ``static auto-property with explicit type`` () =
formatSourceString
"""
type X() =
static member val Count: int = 0 with get, set
"""
config
|> prepend newline
|> should
equal
"""
type X() =
static member val Count: int = 0 with get, set
"""

[<Test>]
let ``public get, private set`` () =
formatSourceString
Expand Down
72 changes: 72 additions & 0 deletions src/Fantomas.Core.Tests/BeginEndTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,78 @@ open NUnit.Framework
open FsUnit
open Fantomas.Core.Tests.TestHelpers

[<Test>]
let ``begin end in value binding`` () =
formatSourceString
"""
let x = begin 42 end
"""
config
|> prepend newline
|> should
equal
"""
let x = begin 42 end
"""

[<Test>]
let ``begin end in function body`` () =
formatSourceString
"""
let f x = begin x + 1 end
"""
config
|> prepend newline
|> should
equal
"""
let f x = begin x + 1 end
"""

[<Test>]
let ``begin end in match branch`` () =
formatSourceString
"""
let g x =
match x with
| 0 -> begin 1 end
| _ -> begin 2 end
"""
config
|> prepend newline
|> should
equal
"""
let g x =
match x with
| 0 -> begin 1 end
| _ -> begin 2 end
"""

[<Test>]
let ``begin end with comment inside`` () =
formatSourceString
"""
do
begin
// hello
let a = 1
a
end
"""
config
|> prepend newline
|> should
equal
"""
do
begin
// hello
let a = 1
a
end
"""

[<Test>]
let ``detect begin end from SynExpr.Paren, 2368`` () =
formatSourceString
Expand Down