-
-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial chain proof of concept. (#2696)
* Initial chain proof of concept. * Update test result according to proposal. * Trivia inside chain. * Remove obsolete ExprDotGetAppWithLambdaNode * Excluded ExprAppWithLambdaNode in Chain. * Update src/Fantomas.Core.Tests/ChainTests.fs Co-authored-by: dawe <[email protected]> * Add release notes for 5.2.0-alpha-011. Co-authored-by: dawe <[email protected]>
- Loading branch information
Showing
18 changed files
with
898 additions
and
704 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.