Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract setting for preference of newline placement for computation expressions #2746

Merged
merged 19 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from 9 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
679 changes: 679 additions & 0 deletions src/Fantomas.Core.Tests/ComputationExpressionSameLineTests.fs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/Fantomas.Core.Tests/Fantomas.Core.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<Compile Include="ListTests.fs" />
<Compile Include="CompilerDirectivesTests.fs" />
<Compile Include="ComputationExpressionTests.fs" />
<Compile Include="ComputationExpressionSameLineTests.fs" />
<Compile Include="TypeProviderTests.fs" />
<Compile Include="FormattingSelectionOnlyTests.fs" />
<Compile Include="ValidationTests.fs" />
Expand Down
68 changes: 0 additions & 68 deletions src/Fantomas.Core.Tests/Stroustrup/DotIndexedSetExpressionTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -96,28 +96,6 @@ myMutable.[x] <- struct {|
|}
"""

[<Test>]
let ``dotIndexedSet with computation expression`` () =
formatSourceString
false
"""
myMutable.[x] <-
task {
// some computation here
()
}
"""
config
|> prepend newline
|> should
equal
"""
myMutable.[x] <- task {
// some computation here
()
}
"""

[<Test>]
let ``dotIndexedSet with list`` () =
formatSourceString
Expand Down Expand Up @@ -256,28 +234,6 @@ app().[x] <- struct {|
|}
"""

[<Test>]
let ``application unit dotIndexedSet with computation expression`` () =
formatSourceString
false
"""
app().[x] <-
task {
// some computation here
()
}
"""
config
|> prepend newline
|> should
equal
"""
app().[x] <- task {
// some computation here
()
}
"""

[<Test>]
let ``application unit dotIndexedSet with list`` () =
formatSourceString
Expand Down Expand Up @@ -426,30 +382,6 @@ app(
|}
"""

[<Test>]
let ``application parenthesis expr dotIndexedSet with computation expression`` () =
formatSourceString
false
"""
app(meh).[x] <-
task {
// some computation here
()
}
"""
config
|> prepend newline
|> should
equal
"""
app(
meh
).[x] <- task {
// some computation here
()
}
"""

[<Test>]
let ``application parenthesis expr dotIndexedSet with list`` () =
formatSourceString
Expand Down
22 changes: 0 additions & 22 deletions src/Fantomas.Core.Tests/Stroustrup/DotSetExpressionTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -119,28 +119,6 @@ App().foo <- struct {|
|}
"""

[<Test>]
let ``dotSet with computation expression`` () =
formatSourceString
false
"""
App().foo <-
task {
// some computation here
()
}
"""
config
|> prepend newline
|> should
equal
"""
App().foo <- task {
// some computation here
()
}
"""

[<Test>]
let ``dotSet with list`` () =
formatSourceString
Expand Down
116 changes: 0 additions & 116 deletions src/Fantomas.Core.Tests/Stroustrup/LambdaExpressionTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -96,28 +96,6 @@ fun x -> struct {|
|}
"""

[<Test>]
let ``lambda with computation expression`` () =
formatSourceString
false
"""
fun x ->
task {
// some computation here
()
}
"""
config
|> prepend newline
|> should
equal
"""
fun x -> task {
// some computation here
()
}
"""

[<Test>]
let ``lambda with list`` () =
formatSourceString
Expand Down Expand Up @@ -256,28 +234,6 @@ let ``paren lambda with anonymous record instance struct`` () =
|})
"""

[<Test>]
let ``paren lambda with computation expression`` () =
formatSourceString
false
"""
(fun x ->
task {
// some computation here
()
})
"""
config
|> prepend newline
|> should
equal
"""
(fun x -> task {
// some computation here
()
})
"""

[<Test>]
let ``paren lambda with list`` () =
formatSourceString
Expand Down Expand Up @@ -416,28 +372,6 @@ List.map (fun x -> struct {|
|})
"""

[<Test>]
let ``app paren lambda with computation expression`` () =
formatSourceString
false
"""
List.map (fun x ->
task {
// some computation here
()
})
"""
config
|> prepend newline
|> should
equal
"""
List.map (fun x -> task {
// some computation here
()
})
"""

[<Test>]
let ``app paren lambda with list`` () =
formatSourceString
Expand Down Expand Up @@ -588,31 +522,6 @@ List.map
c
"""

[<Test>]
let ``app paren lambda with computation expression and other args`` () =
formatSourceString
false
"""
List.map (fun x ->
task {
// some computation here
()
}) b c
"""
config
|> prepend newline
|> should
equal
"""
List.map
(fun x -> task {
// some computation here
()
})
b
c
"""

[<Test>]
let ``app paren lambda with list and other args`` () =
formatSourceString
Expand Down Expand Up @@ -773,31 +682,6 @@ Bar
.Bar()
"""

[<Test>]
let ``dotGetApp with lambda with computation expression`` () =
formatSourceString
false
"""
Bar
.Foo(fun x ->
task {
// some computation here
()
}).Bar()
"""
config
|> prepend newline
|> should
equal
"""
Bar
.Foo(fun x -> task {
// some computation here
()
})
.Bar()
"""

[<Test>]
let ``dotGetApp with lambda with list`` () =
formatSourceString
Expand Down
29 changes: 0 additions & 29 deletions src/Fantomas.Core.Tests/Stroustrup/LetOrUseBangExpressionTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -131,35 +131,6 @@ opt {
}
"""

[<Test>]
let ``letOrUseBang with computation expression`` () =
formatSourceString
false
"""
task {
let! meh =
task {
// comment
return 42
}
()
}
"""
config
|> prepend newline
|> should
equal
"""
task {
let! meh = task {
// comment
return 42
}

()
}
"""

[<Test>]
let ``letOrUseBang with list`` () =
formatSourceString
Expand Down
22 changes: 0 additions & 22 deletions src/Fantomas.Core.Tests/Stroustrup/LongIdentSetExpressionTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -96,28 +96,6 @@ myMutable <- struct {|
|}
"""

[<Test>]
let ``longIdentSet with computation expression`` () =
formatSourceString
false
"""
myMutable <-
task {
// some computation here
()
}
"""
config
|> prepend newline
|> should
equal
"""
myMutable <- task {
// some computation here
()
}
"""

[<Test>]
let ``longIdentSet with list`` () =
formatSourceString
Expand Down
Loading