Skip to content

Commit

Permalink
Add scala3 tests for if-then, for/while-do
Browse files Browse the repository at this point in the history
Also, adjust some existing tests so that they are not overflowing the
line anymore (which would trigger a newline in the next commit); and
for classic/keep tests with `danglingParens.ctrlSite=false`, there's
no break before then/do which would also be preserved later and hence
ignore the `ctrlSite` setting.
  • Loading branch information
kitbellew committed Jan 10, 2022
1 parent 944025f commit e5e2b1a
Show file tree
Hide file tree
Showing 4 changed files with 869 additions and 32 deletions.
197 changes: 185 additions & 12 deletions scalafmt-tests/src/test/resources/scala3/OptionalBraces.stat
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,7 @@ object a:
bar
def foo =
for
x <- y
do
x <- y do
bar
>>>
object a:
Expand Down Expand Up @@ -1459,7 +1458,7 @@ object a:
c
do foo
<<< if break before then if multiline cond, !dangle
maxColumn = 12
maxColumn = 15
indent.callSite = 4
indent.ctrlSite = 6
danglingParentheses.ctrlSite = false
Expand All @@ -1476,7 +1475,7 @@ object a:
c then
foo
<<< while break before do if multiline cond, !dangle
maxColumn = 12
maxColumn = 13
indent.callSite = 4
indent.ctrlSite = 6
danglingParentheses.ctrlSite = false
Expand Down Expand Up @@ -1896,8 +1895,7 @@ danglingParentheses.ctrlSite = false
===
if // comm
val cond1 = true
(a1 && a2) == cond1
then
(a1 && a2) == cond1 then
val exitCode = 1
exitCode

Expand All @@ -1911,8 +1909,7 @@ if // comm
danglingParentheses.ctrlSite = false
===
if
(a1 && a2) == cond1
then
(a1 && a2) == cond1 then
val exitCode = 1
exitCode

Expand All @@ -1925,8 +1922,7 @@ danglingParentheses.ctrlSite = false
===
while // comm
val cond1 = true
(a1 && a2) == cond1
do
(a1 && a2) == cond1 do
val exitCode = 1
exitCode

Expand All @@ -1940,8 +1936,7 @@ while // comm
danglingParentheses.ctrlSite = false
===
while
(a1 && a2) == cond1
do
(a1 && a2) == cond1 do
val exitCode = 1
exitCode

Expand Down Expand Up @@ -3101,3 +3096,181 @@ object a:
for (m <- 0 until 10) do
val msg = m.toString
received += msg
<<< #3033 if-then danglingParentheses
maxColumn = 15
danglingParentheses.ctrlSite = true
===
class C:
if true
then 3
else 4
if true
then
3
else 4
if
true
then
3
else 4
>>>
class C:
if true then
3
else 4
if true then
3
else 4
if true then
3
else 4
<<< #3033 if-then !danglingParentheses
maxColumn = 15
danglingParentheses.ctrlSite = false
===
class C:
if true
then 3
else 4
if true
then
3
else 4
if
true
then
3
else 4
>>>
class C:
if true then
3
else 4
if true then
3
else 4
if true then
3
else 4
<<< #3034 for-yield danglingParentheses
danglingParentheses.ctrlSite = true
===
object a:
for x <- range
yield matrix(x)(0) += matrix(x - 1)(0)
for x <- range
yield
matrix(x)(0) += matrix(x - 1)(0)
>>>
object a:
for x <- range
yield matrix(x)(0) += matrix(x - 1)(0)
for x <- range
yield matrix(x)(0) += matrix(x - 1)(0)
<<< #3034 for-yield !danglingParentheses
danglingParentheses.ctrlSite = false
===
object a:
for x <- range
yield matrix(x)(0) += matrix(x - 1)(0)
for x <- range
yield
matrix(x)(0) += matrix(x - 1)(0)
>>>
object a:
for x <- range
yield matrix(x)(0) += matrix(x - 1)(0)
for x <- range
yield matrix(x)(0) += matrix(x - 1)(0)
<<< #3034 for-do danglingParentheses
danglingParentheses.ctrlSite = true
===
object a:
for x <- range
do matrix(x)(0) += matrix(x - 1)(0)
for x <- range do
matrix(x)(0) += matrix(x - 1)(0)
for x <- range
do
matrix(x)(0) += matrix(x - 1)(0)
for
x <- range
do
matrix(x)(0) += matrix(x - 1)(0)
>>>
object a:
for x <- range do matrix(x)(0) += matrix(x - 1)(0)
for x <- range do matrix(x)(0) += matrix(x - 1)(0)
for x <- range do matrix(x)(0) += matrix(x - 1)(0)
for x <- range do matrix(x)(0) += matrix(x - 1)(0)
<<< #3034 for-do !danglingParentheses
danglingParentheses.ctrlSite = false
===
object a:
for x <- range
do matrix(x)(0) += matrix(x - 1)(0)
for x <- range do
matrix(x)(0) += matrix(x - 1)(0)
for x <- range
do
matrix(x)(0) += matrix(x - 1)(0)
for
x <- range
do
matrix(x)(0) += matrix(x - 1)(0)
>>>
object a:
for x <- range do matrix(x)(0) += matrix(x - 1)(0)
for x <- range do matrix(x)(0) += matrix(x - 1)(0)
for x <- range do matrix(x)(0) += matrix(x - 1)(0)
for x <- range do matrix(x)(0) += matrix(x - 1)(0)
<<< #3034 while-do danglingParentheses
danglingParentheses.ctrlSite = true
===
object a:
while x < range
do matrix(x)(0) += matrix(x - 1)(0)
while x < range do
matrix(x)(0) += matrix(x - 1)(0)
while
x < range
do matrix(x)(0) += matrix(x - 1)(0)
while x < range
do
matrix(x)(0) += matrix(x - 1)(0)
while
x < range
do
matrix(x)(0) += matrix(x - 1)(0)
>>>
object a:
while x < range do matrix(x)(0) += matrix(x - 1)(0)
while x < range do matrix(x)(0) += matrix(x - 1)(0)
while x < range do matrix(x)(0) += matrix(x - 1)(0)
while x < range do matrix(x)(0) += matrix(x - 1)(0)
while x < range do matrix(x)(0) += matrix(x - 1)(0)
<<< #3034 while-do !danglingParentheses
danglingParentheses.ctrlSite = false
===
object a:
while x < range
do matrix(x)(0) += matrix(x - 1)(0)
while x < range do
matrix(x)(0) += matrix(x - 1)(0)
while
x < range
do matrix(x)(0) += matrix(x - 1)(0)
while x < range
do
matrix(x)(0) += matrix(x - 1)(0)
while
x < range
do
matrix(x)(0) += matrix(x - 1)(0)
>>>
object a:
while x < range do matrix(x)(0) += matrix(x - 1)(0)
while x < range do matrix(x)(0) += matrix(x - 1)(0)
while x < range do matrix(x)(0) += matrix(x - 1)(0)
while x < range do matrix(x)(0) += matrix(x - 1)(0)
while x < range do matrix(x)(0) += matrix(x - 1)(0)
Loading

0 comments on commit e5e2b1a

Please sign in to comment.