Skip to content

Commit

Permalink
Test if-else with one side a block
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Nov 22, 2024
1 parent 83f68e0 commit 59b5bec
Show file tree
Hide file tree
Showing 5 changed files with 214 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11201,3 +11201,51 @@ extends SomeBaseClass
with SomeTrait
>>>
class SomeClass(a: Int, b: Double, c: String) extends SomeBaseClass with SomeTrait
<<< if-else with one block, short
maxColumn = 40
===
object a {
if (s.costWithPenalty > 0) { preFork = false; false } else true

if (s.costWithPenalty <= 0) true else { preFork = false; false }
}
>>>
object a {
if (s.costWithPenalty > 0) {
preFork = false; false
} else true

if (s.costWithPenalty <= 0) true
else { preFork = false; false }
}
<<< if-else with one block, medium
maxColumn = 60
===
object a {
if (s.costWithPenalty > 0) { preFork = false; false } else true

if (s.costWithPenalty <= 0) true else { preFork = false; false }
}
>>>
object a {
if (s.costWithPenalty > 0) { preFork = false; false }
else true

if (s.costWithPenalty <= 0) true
else { preFork = false; false }
}
<<< if-else with one block, long
maxColumn = 80
===
object a {
if (s.costWithPenalty > 0) { preFork = false; false } else true

if (s.costWithPenalty <= 0) true else { preFork = false; false }
}
>>>
object a {
if (s.costWithPenalty > 0) { preFork = false; false }
else true

if (s.costWithPenalty <= 0) true else { preFork = false; false }
}
48 changes: 48 additions & 0 deletions scalafmt-tests/shared/src/test/resources/newlines/source_fold.stat
Original file line number Diff line number Diff line change
Expand Up @@ -10467,3 +10467,51 @@ extends SomeBaseClass
with SomeTrait
>>>
class SomeClass(a: Int, b: Double, c: String) extends SomeBaseClass with SomeTrait
<<< if-else with one block, short
maxColumn = 40
===
object a {
if (s.costWithPenalty > 0) { preFork = false; false } else true

if (s.costWithPenalty <= 0) true else { preFork = false; false }
}
>>>
object a {
if (s.costWithPenalty > 0) {
preFork = false; false
} else true

if (s.costWithPenalty <= 0) true
else { preFork = false; false }
}
<<< if-else with one block, medium
maxColumn = 60
===
object a {
if (s.costWithPenalty > 0) { preFork = false; false } else true

if (s.costWithPenalty <= 0) true else { preFork = false; false }
}
>>>
object a {
if (s.costWithPenalty > 0) { preFork = false; false }
else true

if (s.costWithPenalty <= 0) true
else { preFork = false; false }
}
<<< if-else with one block, long
maxColumn = 80
===
object a {
if (s.costWithPenalty > 0) { preFork = false; false } else true

if (s.costWithPenalty <= 0) true else { preFork = false; false }
}
>>>
object a {
if (s.costWithPenalty > 0) { preFork = false; false }
else true

if (s.costWithPenalty <= 0) true else { preFork = false; false }
}
48 changes: 48 additions & 0 deletions scalafmt-tests/shared/src/test/resources/newlines/source_keep.stat
Original file line number Diff line number Diff line change
Expand Up @@ -10953,3 +10953,51 @@ with SomeTrait
class SomeClass(a: Int, b: Double, c: String)
extends SomeBaseClass
with SomeTrait
<<< if-else with one block, short
maxColumn = 40
===
object a {
if (s.costWithPenalty > 0) { preFork = false; false } else true

if (s.costWithPenalty <= 0) true else { preFork = false; false }
}
>>>
object a {
if (s.costWithPenalty > 0) {
preFork = false; false
} else true

if (s.costWithPenalty <= 0) true
else { preFork = false; false }
}
<<< if-else with one block, medium
maxColumn = 60
===
object a {
if (s.costWithPenalty > 0) { preFork = false; false } else true

if (s.costWithPenalty <= 0) true else { preFork = false; false }
}
>>>
object a {
if (s.costWithPenalty > 0) { preFork = false; false }
else true

if (s.costWithPenalty <= 0) true
else { preFork = false; false }
}
<<< if-else with one block, long
maxColumn = 80
===
object a {
if (s.costWithPenalty > 0) { preFork = false; false } else true

if (s.costWithPenalty <= 0) true else { preFork = false; false }
}
>>>
object a {
if (s.costWithPenalty > 0) { preFork = false; false }
else true

if (s.costWithPenalty <= 0) true else { preFork = false; false }
}
Original file line number Diff line number Diff line change
Expand Up @@ -11360,3 +11360,72 @@ extends SomeBaseClass
with SomeTrait
>>>
class SomeClass(a: Int, b: Double, c: String) extends SomeBaseClass with SomeTrait
<<< if-else with one block, short
maxColumn = 40
===
object a {
if (s.costWithPenalty > 0) { preFork = false; false } else true

if (s.costWithPenalty <= 0) true else { preFork = false; false }
}
>>>
object a {
if (s.costWithPenalty > 0) {
preFork = false;
false
} else
true

if (s.costWithPenalty <= 0)
true
else {
preFork = false;
false
}
}
<<< if-else with one block, medium
maxColumn = 60
===
object a {
if (s.costWithPenalty > 0) { preFork = false; false } else true

if (s.costWithPenalty <= 0) true else { preFork = false; false }
}
>>>
object a {
if (s.costWithPenalty > 0) {
preFork = false;
false
} else
true

if (s.costWithPenalty <= 0)
true
else {
preFork = false;
false
}
}
<<< if-else with one block, long
maxColumn = 80
===
object a {
if (s.costWithPenalty > 0) { preFork = false; false } else true

if (s.costWithPenalty <= 0) true else { preFork = false; false }
}
>>>
object a {
if (s.costWithPenalty > 0) {
preFork = false;
false
} else
true

if (s.costWithPenalty <= 0)
true
else {
preFork = false;
false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class FormatTests extends FunSuite with CanRunTests with FormatAssertions {
val explored = Debug.explored.get()
logger.debug(s"Total explored: $explored")
if (!onlyUnit && !onlyManual)
assertEquals(explored, 1084768, "total explored")
assertEquals(explored, 1086266, "total explored")
val results = debugResults.result()
// TODO(olafur) don't block printing out test results.
// I don't want to deal with scalaz's Tasks :'(
Expand Down

0 comments on commit 59b5bec

Please sign in to comment.