This is an automated email from the ASF dual-hosted git repository. joshtynjala pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/royale-compiler.git
commit c02f89782e4e670128e45f39ecd8f9c9a589fa1b Author: Josh Tynjala <[email protected]> AuthorDate: Wed Sep 27 09:54:12 2023 -0700 formatter: extra test for function return type and brace placement --- .../royale/formatter/TestFunctionDeclaration.java | 28 +++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/formatter/src/test/java/org/apache/royale/formatter/TestFunctionDeclaration.java b/formatter/src/test/java/org/apache/royale/formatter/TestFunctionDeclaration.java index 7c60fd237..89c26fc4e 100644 --- a/formatter/src/test/java/org/apache/royale/formatter/TestFunctionDeclaration.java +++ b/formatter/src/test/java/org/apache/royale/formatter/TestFunctionDeclaration.java @@ -218,7 +218,7 @@ public class TestFunctionDeclaration extends BaseFormatterTests { } @Test - public void testReturnType() { + public void testPlaceOpenBraceOnNewLineWithReturnType() { FormatterSettings settings = new FormatterSettings(); settings.insertSpaceAfterKeywordsInControlFlowStatements = true; settings.placeOpenBraceOnNewLine = true; @@ -243,6 +243,32 @@ public class TestFunctionDeclaration extends BaseFormatterTests { result); } + + @Test + public void testDisablePlaceOpenBraceOnNewLineWithReturnType() { + FormatterSettings settings = new FormatterSettings(); + settings.insertSpaceAfterKeywordsInControlFlowStatements = true; + settings.placeOpenBraceOnNewLine = false; + settings.insertSpaces = false; + ASTokenFormatter formatter = new ASTokenFormatter(settings); + String result = formatter.format("file.as", + // @formatter:off + "function myFunction():void\n" + + "{\n" + + "\tstatement;\n" + + "}", + // @formatter:on + problems + ); + assertEquals( + // @formatter:off + "function myFunction():void {\n" + + "\tstatement;\n" + + "}", + // @formatter:on + result); + } + @Test public void testParameter() { FormatterSettings settings = new FormatterSettings();
