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

Initial chain proof of concept. #2696

Merged
merged 7 commits into from
Jan 12, 2023
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
10 changes: 4 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

## Unreleased
## [5.2.0-alpha-011] - 2023-01-12

### Fixes
* Stroustrup: Two lists given directly as parameters, break code [#2681](https://github.com/fsprojects/fantomas/issues/2681)
Expand All @@ -10,11 +10,9 @@
* Piped multiline application is indented too far. [#2682](https://github.com/fsprojects/fantomas/issues/2682)
* Comment not assigned to first parameter in constructor. [#2692](https://github.com/fsprojects/fantomas/issues/2692)
* Stroustrup: Type alias for anonymous record type. [#2179](https://github.com/fsprojects/fantomas/issues/2179)

## [5.2.0-beta-001] - 2023-01-02

### Changed
* Consider v5.2 to be stable and production ready.
* Space before lambda should not occur in chain. [#2685](https://github.com/fsprojects/fantomas/issues/2685)
* Trivia inside chained lambda is not restored correctly. [#2686](https://github.com/fsprojects/fantomas/issues/2686)
* SpaceBeforeUppercaseInvocation not respected in TypeApp DotGet. [#2700](https://github.com/fsprojects/fantomas/issues/2700)

## [5.2.0-alpha-010] - 2022-12-30

Expand Down
282 changes: 282 additions & 0 deletions src/Fantomas.Core.Tests/ChainTests.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,282 @@
module Fantomas.Core.Tests.ChainTests

open NUnit.Framework
open FsUnit
open Fantomas.Core.Tests.TestHelper

[<Test>]
let ``appUnit dot identifier`` () =
formatSourceString
false
"""
X().Y
"""
config
|> prepend newline
|> should
equal
"""
X().Y
"""

[<Test>]
let ``appParen dot identifier`` () =
formatSourceString
false
"""
X(a).Y
"""
config
|> prepend newline
|> should
equal
"""
X(a).Y
"""

[<Test>]
let ``appUnit dot appUnit`` () =
formatSourceString
false
"""
X().Y()
"""
config
|> prepend newline
|> should
equal
"""
X().Y()
"""

[<Test>]
let ``typed appUnit dot identifier`` () =
formatSourceString
false
"""
X<a>().Y
X<a>().Y<b>()
"""
config
|> prepend newline
|> should
equal
"""
X<a>().Y
X<a>().Y<b>()
"""

[<Test>]
let ``appParenLambda dot identifier`` () =
formatSourceString
false
"""
X(fun x -> x).Y
"""
config
|> prepend newline
|> should
equal
"""
X(fun x -> x).Y
"""

[<Test>]
let ``identifier dot appUnit dot identifier`` () =
formatSourceString
false
"""
X.Y().Z
"""
config
|> prepend newline
|> should
equal
"""
X.Y().Z
"""

[<Test>]
let ``identifier dot indexed expr dot identifier`` () =
formatSourceString
false
"""
A.[0].B
"""
config
|> prepend newline
|> should
equal
"""
A.[0].B
"""

[<Test>]
let ``identifier dot indexed expr dot appParenExpr`` () =
formatSourceString
false
"""
A.[0].B(1)
"""
config
|> prepend newline
|> should
equal
"""
A.[0].B(1)
"""

[<Test>]
let ``identifier dot typed appUnit dot identifier`` () =
formatSourceString
false
"""
X.Y<a>().Z
"""
config
|> prepend newline
|> should
equal
"""
X.Y<a>().Z
"""

[<Test>]
let ``identifier dot typed identifier dot identifier`` () =
formatSourceString
false
"""
X.Y<a>.Z
"""
config
|> prepend newline
|> should
equal
"""
X.Y<a>.Z
"""

[<Test>]
let ``appUnit dot appParen`` () =
formatSourceString
false
"""
A().B(fun b -> b)
"""
config
|> prepend newline
|> should
equal
"""
A().B(fun b -> b)
"""

[<Test>]
let ``identifier dot appUnit dot typed appUnit `` () =
formatSourceString
false
"""
A.B().C<'d>()
"""
{ config with
MaxDotGetExpressionWidth = 0 }
|> prepend newline
|> should
equal
"""
A
.B()
.C<'d>()
"""

[<Test>]
let ``identifier dot appUnit dot typed identifier `` () =
formatSourceString
false
"""
A.B().C<'d>
"""
{ config with
MaxDotGetExpressionWidth = 0 }
|> prepend newline
|> should
equal
"""
A
.B()
.C<'d>
"""

[<Test>]
let ``identifier dot identifier dot appExpr dot appUnit dot index expr`` () =
formatSourceString
false
"""
A.B.C(D).E().[0]
"""
{ config with
MaxDotGetExpressionWidth = 0 }
|> prepend newline
|> should
equal
"""
A.B
.C(D)
.E()
.[0]
"""

[<Test>]
let ``identifier dot identifier dot appExpr dot identifier dot index expr`` () =
formatSourceString
false
"""
A.B.C(D).E.[0]
"""
{ config with
MaxDotGetExpressionWidth = 0 }
|> prepend newline
|> should
equal
"""
A.B
.C(D)
.E.[0]
"""

[<Test>]
let ``trivia inside chain, 2686`` () =
formatSourceString
false
"""
builder.
FirstThing<X>(fun lambda ->
// aaaaaa
()
)
.SecondThing<Y>(fun next ->
// bbbbb
next
)
// ccccc
.ThirdThing<Z>().X
"""
{ config with
MultiLineLambdaClosingNewline = true }
|> prepend newline
|> should
equal
"""
builder
.FirstThing<X>(fun lambda ->
// aaaaaa
()
)
.SecondThing<Y>(fun next ->
// bbbbb
next
)
// ccccc
.ThirdThing<Z>()
.X
"""
4 changes: 1 addition & 3 deletions src/Fantomas.Core.Tests/CompilerDirectivesTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2287,9 +2287,7 @@ let loader (projectRoot: string) (siteContent: SiteContents) =
"""
let loadFile n =
let file =
System
.IO
.Path
System.IO.Path
.Combine(
contentDir,
(n |> System.IO.Path.GetFileNameWithoutExtension)
Expand Down
Loading