Skip to content

Commit

Permalink
Test try-catch followed by comment, within braces
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Sep 3, 2024
1 parent fd8f02f commit ec150f2
Show file tree
Hide file tree
Showing 4 changed files with 201 additions and 0 deletions.
48 changes: 48 additions & 0 deletions scalafmt-tests/src/test/resources/scala3/OptionalBraces.stat
Original file line number Diff line number Diff line change
Expand Up @@ -6576,6 +6576,54 @@ object a:

// c2
}
<<< #4133 try-catch with trailing comments 5, in braces
object a {
def foo = try
bar
catch case baz => qux

/** c1 */
def quux = ???
}
>>>
object a {
def foo = try bar
catch
case baz =>
qux

/** c1 */
def quux = ???
}
<<< SKIP #4133 try-catch with trailing comments 6, insert end markers
rewrite.scala3.insertEndMarkerMinLines = 2
===
object a:
def foo =
try
bar
catch case baz => qux

// c1
quux
end foo
>>>
test does not parse: [dialect scala3] expected template body
object a:
^
def foo =
try bar
catch case baz => qux
====== full result: ======
object a:
def foo =
try bar
catch case baz => qux
end try

// c1
quux
end foo
<<< #4133 enclosed new anonymous with comments and added end marker
rewrite.scala3 {
convertToNewSyntax = true
Expand Down
49 changes: 49 additions & 0 deletions scalafmt-tests/src/test/resources/scala3/OptionalBraces_fold.stat
Original file line number Diff line number Diff line change
Expand Up @@ -6308,6 +6308,55 @@ object a:

// c2
}
<<< #4133 try-catch with trailing comments 5, in braces
object a {
def foo = try
bar
catch case baz => qux

/** c1 */
def quux = ???
}
>>>
object a {
def foo =
try bar
catch
case baz =>
qux

/** c1 */
def quux = ???
}
<<< SKIP #4133 try-catch with trailing comments 6, insert end markers
rewrite.scala3.insertEndMarkerMinLines = 2
===
object a:
def foo =
try
bar
catch case baz => qux

// c1
quux
end foo
>>>
test does not parse: [dialect scala3] expected template body
object a:
^
def foo =
try bar
catch case baz => qux
====== full result: ======
object a:
def foo =
try bar
catch case baz => qux
end try

// c1
quux
end foo
<<< #4133 enclosed new anonymous with comments and added end marker
rewrite.scala3 {
convertToNewSyntax = true
Expand Down
51 changes: 51 additions & 0 deletions scalafmt-tests/src/test/resources/scala3/OptionalBraces_keep.stat
Original file line number Diff line number Diff line change
Expand Up @@ -6606,6 +6606,57 @@ object a:

// c2
}
<<< #4133 try-catch with trailing comments 5, in braces
object a {
def foo = try
bar
catch case baz => qux

/** c1 */
def quux = ???
}
>>>
object a {
def foo =
try
bar
catch
case baz =>
qux

/** c1 */
def quux = ???
}
<<< SKIP #4133 try-catch with trailing comments 6, insert end markers
rewrite.scala3.insertEndMarkerMinLines = 2
===
object a:
def foo =
try
bar
catch case baz => qux

// c1
quux
end foo
>>>
test does not parse: [dialect scala3] expected template body
object a:
^
def foo =
try
bar
====== full result: ======
object a:
def foo =
try
bar
catch case baz => qux
end try

// c1
quux
end foo
<<< #4133 enclosed new anonymous with comments and added end marker
rewrite.scala3 {
convertToNewSyntax = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6774,6 +6774,59 @@ object a:

// c2
}
<<< #4133 try-catch with trailing comments 5, in braces
object a {
def foo = try
bar
catch case baz => qux

/** c1 */
def quux = ???
}
>>>
object a {
def foo =
try
bar
catch
case baz =>
qux

/** c1 */
def quux = ???
}
<<< SKIP #4133 try-catch with trailing comments 6, insert end markers
rewrite.scala3.insertEndMarkerMinLines = 2
===
object a:
def foo =
try
bar
catch case baz => qux

// c1
quux
end foo
>>>
test does not parse: [dialect scala3] expected template body
object a:
^
def foo =
try
bar
====== full result: ======
object a:
def foo =
try
bar
catch
case baz =>
qux
end try

// c1
quux
end foo
<<< #4133 enclosed new anonymous with comments and added end marker
rewrite.scala3 {
convertToNewSyntax = true
Expand Down

0 comments on commit ec150f2

Please sign in to comment.