Skip to content

Commit

Permalink
Add tests with opt-braces rewrite and new anon
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Jul 7, 2023
1 parent 967040e commit 87d16e4
Show file tree
Hide file tree
Showing 4 changed files with 309 additions and 0 deletions.
77 changes: 77 additions & 0 deletions scalafmt-tests/src/test/resources/scala3/OptionalBraces.stat
Original file line number Diff line number Diff line change
Expand Up @@ -5004,6 +5004,27 @@ object A:
new Foo("xyz"):
print("msg")
.bar()
<<< match inside infix chain, with rewrite
rewrite.scala3.removeOptionalBraces = yes
===
object a {
withEval.so(evalComment so { c =>
s"($c) "
}) +
this.match {
case MateAdvice(seq, _, _, _) => seq.desc
case CpAdvice(judgment, _, _) => judgment.toString
} + "."
}
>>>
object a:
withEval.so(evalComment so { c =>
s"($c) "
}) +
this.match
case MateAdvice(seq, _, _, _) => seq.desc
case CpAdvice(judgment, _, _) => judgment.toString
+ "."
<<< match as infix lhs, with rewrite
rewrite.scala3.removeOptionalBraces = yes
===
Expand Down Expand Up @@ -5043,3 +5064,59 @@ def foo(url: String) =
.map { img =>
Html(s"""<img class="embed" src="$img" alt="$url"/>""")
}
<<< new anon as infix lhs, with rewrite
rewrite.scala3.removeOptionalBraces = yes
===
object a {
new AdapterLike[Study] {
def query = Query(text take 100, me.map(_.id))
def nbResults = api count query
def slice(offset: Int, length: Int) = api.search(query, From(offset), Size(length))
} mapFutureList pager.withChaptersAndLiking(me)
}
>>>
test does not parse
object a:
new AdapterLike[Study]:
def query = Query(text take 100, me.map(_.id))
def nbResults = api count query
def slice(offset: Int, length: Int) =
api.search(query, From(offset), Size(length))
mapFutureList pager.withChaptersAndLiking(me)
^
<<< new anon as postfix lhs, with rewrite
rewrite.scala3.removeOptionalBraces = yes
===
object a {
new AdapterLike[Study] {
def query = Query(text take 100, me.map(_.id))
def nbResults = api count query
def slice(offset: Int, length: Int) = api.search(query, From(offset), Size(length))
} mapFutureList
}
>>>
object a:
new AdapterLike[Study]:
def query = Query(text take 100, me.map(_.id))
def nbResults = api count query
def slice(offset: Int, length: Int) =
api.search(query, From(offset), Size(length))
mapFutureList
<<< new anon as select lhs, with rewrite
rewrite.scala3.removeOptionalBraces = yes
===
object a {
new AdapterLike[Study] {
def query = Query(text take 100, me.map(_.id))
def nbResults = api count query
def slice(offset: Int, length: Int) = api.search(query, From(offset), Size(length))
}.mapFutureList
}
>>>
object a:
new AdapterLike[Study]:
def query = Query(text take 100, me.map(_.id))
def nbResults = api count query
def slice(offset: Int, length: Int) =
api.search(query, From(offset), Size(length))
.mapFutureList
74 changes: 74 additions & 0 deletions scalafmt-tests/src/test/resources/scala3/OptionalBraces_fold.stat
Original file line number Diff line number Diff line change
Expand Up @@ -4789,6 +4789,24 @@ object A:
new Foo("xyz"):
print("msg")
.bar()
<<< match inside infix chain, with rewrite
rewrite.scala3.removeOptionalBraces = yes
===
object a {
withEval.so(evalComment so { c =>
s"($c) "
}) +
this.match {
case MateAdvice(seq, _, _, _) => seq.desc
case CpAdvice(judgment, _, _) => judgment.toString
} + "."
}
>>>
object a:
withEval.so(evalComment so { c => s"($c) " }) + this.match
case MateAdvice(seq, _, _, _) => seq.desc
case CpAdvice(judgment, _, _) => judgment.toString
+ "."
<<< match as infix lhs, with rewrite
rewrite.scala3.removeOptionalBraces = yes
===
Expand Down Expand Up @@ -4822,3 +4840,59 @@ def foo(url: String) = url.match
case "foo" => Some("")
case _ => None
.map { img => Html(s"""<img class="embed" src="$img" alt="$url"/>""") }
<<< new anon as infix lhs, with rewrite
rewrite.scala3.removeOptionalBraces = yes
===
object a {
new AdapterLike[Study] {
def query = Query(text take 100, me.map(_.id))
def nbResults = api count query
def slice(offset: Int, length: Int) = api.search(query, From(offset), Size(length))
} mapFutureList pager.withChaptersAndLiking(me)
}
>>>
test does not parse
object a:
new AdapterLike[Study]:
def query = Query(text take 100, me.map(_.id))
def nbResults = api count query
def slice(offset: Int, length: Int) = api
.search(query, From(offset), Size(length))
mapFutureList pager.withChaptersAndLiking(me)
^
<<< new anon as postfix lhs, with rewrite
rewrite.scala3.removeOptionalBraces = yes
===
object a {
new AdapterLike[Study] {
def query = Query(text take 100, me.map(_.id))
def nbResults = api count query
def slice(offset: Int, length: Int) = api.search(query, From(offset), Size(length))
} mapFutureList
}
>>>
object a:
new AdapterLike[Study]:
def query = Query(text take 100, me.map(_.id))
def nbResults = api count query
def slice(offset: Int, length: Int) = api
.search(query, From(offset), Size(length))
mapFutureList
<<< new anon as select lhs, with rewrite
rewrite.scala3.removeOptionalBraces = yes
===
object a {
new AdapterLike[Study] {
def query = Query(text take 100, me.map(_.id))
def nbResults = api count query
def slice(offset: Int, length: Int) = api.search(query, From(offset), Size(length))
}.mapFutureList
}
>>>
object a:
new AdapterLike[Study]:
def query = Query(text take 100, me.map(_.id))
def nbResults = api count query
def slice(offset: Int, length: Int) = api
.search(query, From(offset), Size(length))
.mapFutureList
77 changes: 77 additions & 0 deletions scalafmt-tests/src/test/resources/scala3/OptionalBraces_keep.stat
Original file line number Diff line number Diff line change
Expand Up @@ -5036,6 +5036,27 @@ object A:
new Foo("xyz"):
print("msg")
.bar()
<<< match inside infix chain, with rewrite
rewrite.scala3.removeOptionalBraces = yes
===
object a {
withEval.so(evalComment so { c =>
s"($c) "
}) +
this.match {
case MateAdvice(seq, _, _, _) => seq.desc
case CpAdvice(judgment, _, _) => judgment.toString
} + "."
}
>>>
object a:
withEval.so(evalComment so { c =>
s"($c) "
}) +
this.match
case MateAdvice(seq, _, _, _) => seq.desc
case CpAdvice(judgment, _, _) => judgment.toString
+ "."
<<< match as infix lhs, with rewrite
rewrite.scala3.removeOptionalBraces = yes
===
Expand Down Expand Up @@ -5074,3 +5095,59 @@ def foo(url: String) =
.map { img =>
Html(s"""<img class="embed" src="$img" alt="$url"/>""")
}
<<< new anon as infix lhs, with rewrite
rewrite.scala3.removeOptionalBraces = yes
===
object a {
new AdapterLike[Study] {
def query = Query(text take 100, me.map(_.id))
def nbResults = api count query
def slice(offset: Int, length: Int) = api.search(query, From(offset), Size(length))
} mapFutureList pager.withChaptersAndLiking(me)
}
>>>
test does not parse
object a:
new AdapterLike[Study]:
def query = Query(text take 100, me.map(_.id))
def nbResults = api count query
def slice(offset: Int, length: Int) =
api.search(query, From(offset), Size(length))
mapFutureList pager.withChaptersAndLiking(me)
^
<<< new anon as postfix lhs, with rewrite
rewrite.scala3.removeOptionalBraces = yes
===
object a {
new AdapterLike[Study] {
def query = Query(text take 100, me.map(_.id))
def nbResults = api count query
def slice(offset: Int, length: Int) = api.search(query, From(offset), Size(length))
} mapFutureList
}
>>>
object a:
new AdapterLike[Study]:
def query = Query(text take 100, me.map(_.id))
def nbResults = api count query
def slice(offset: Int, length: Int) =
api.search(query, From(offset), Size(length))
mapFutureList
<<< new anon as select lhs, with rewrite
rewrite.scala3.removeOptionalBraces = yes
===
object a {
new AdapterLike[Study] {
def query = Query(text take 100, me.map(_.id))
def nbResults = api count query
def slice(offset: Int, length: Int) = api.search(query, From(offset), Size(length))
}.mapFutureList
}
>>>
object a:
new AdapterLike[Study]:
def query = Query(text take 100, me.map(_.id))
def nbResults = api count query
def slice(offset: Int, length: Int) =
api.search(query, From(offset), Size(length))
.mapFutureList
Original file line number Diff line number Diff line change
Expand Up @@ -5157,6 +5157,31 @@ object A:
new Foo("xyz"):
print("msg")
.bar()
<<< match inside infix chain, with rewrite
rewrite.scala3.removeOptionalBraces = yes
===
object a {
withEval.so(evalComment so { c =>
s"($c) "
}) +
this.match {
case MateAdvice(seq, _, _, _) => seq.desc
case CpAdvice(judgment, _, _) => judgment.toString
} + "."
}
>>>
object a:
withEval.so(
evalComment so { c =>
s"($c) "
}
) +
this.match
case MateAdvice(seq, _, _, _) =>
seq.desc
case CpAdvice(judgment, _, _) =>
judgment.toString
+ "."
<<< match as infix lhs, with rewrite
rewrite.scala3.removeOptionalBraces = yes
===
Expand Down Expand Up @@ -5200,3 +5225,59 @@ def foo(url: String) =
.map { img =>
Html(s"""<img class="embed" src="$img" alt="$url"/>""")
}
<<< new anon as infix lhs, with rewrite
rewrite.scala3.removeOptionalBraces = yes
===
object a {
new AdapterLike[Study] {
def query = Query(text take 100, me.map(_.id))
def nbResults = api count query
def slice(offset: Int, length: Int) = api.search(query, From(offset), Size(length))
} mapFutureList pager.withChaptersAndLiking(me)
}
>>>
test does not parse
object a:
new AdapterLike[Study]:
def query = Query(text take 100, me.map(_.id))
def nbResults = api count query
def slice(offset: Int, length: Int) = api
.search(query, From(offset), Size(length))
mapFutureList pager.withChaptersAndLiking(me)
^
<<< new anon as postfix lhs, with rewrite
rewrite.scala3.removeOptionalBraces = yes
===
object a {
new AdapterLike[Study] {
def query = Query(text take 100, me.map(_.id))
def nbResults = api count query
def slice(offset: Int, length: Int) = api.search(query, From(offset), Size(length))
} mapFutureList
}
>>>
object a:
new AdapterLike[Study]:
def query = Query(text take 100, me.map(_.id))
def nbResults = api count query
def slice(offset: Int, length: Int) = api
.search(query, From(offset), Size(length))
mapFutureList
<<< new anon as select lhs, with rewrite
rewrite.scala3.removeOptionalBraces = yes
===
object a {
new AdapterLike[Study] {
def query = Query(text take 100, me.map(_.id))
def nbResults = api count query
def slice(offset: Int, length: Int) = api.search(query, From(offset), Size(length))
}.mapFutureList
}
>>>
object a:
new AdapterLike[Study]:
def query = Query(text take 100, me.map(_.id))
def nbResults = api count query
def slice(offset: Int, length: Int) = api
.search(query, From(offset), Size(length))
.mapFutureList

0 comments on commit 87d16e4

Please sign in to comment.