@Test public void testFeatureCallWithParentheses() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { StringConcatenation _builder = new StringConcatenation(); _builder.append("val it = \"xxxx\""); _builder.newLine(); _builder.append("val j = true && (startsWith(\"x\"))"); _builder.newLine(); it.setExpectation(_builder); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("val it = \"xxxx\""); _builder_1.newLine(); _builder_1.append("val j = true&&(startsWith(\"x\"))"); _builder_1.newLine(); it.setToBeFormatted(_builder_1); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
@Test public void formatTryCatchExpression11() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { final Procedure1<MapBasedPreferenceValues> _function_1 = (MapBasedPreferenceValues it_1) -> { it_1.<Boolean>put(XbaseFormatterPreferenceKeys.whitespaceBetweenKeywordAndParenthesisML, Boolean.valueOf(true)); }; it.preferences(_function_1); StringConcatenation _builder = new StringConcatenation(); _builder.append("try"); _builder.newLine(); _builder.append("\t"); _builder.append("println(\"x\")"); _builder.newLine(); _builder.append("catch (Exception e)"); _builder.newLine(); _builder.append("\t"); _builder.append("println(\"y\")"); _builder.newLine(); it.setToBeFormatted(_builder); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
@Test public void formatClosuresMultiLine03() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { StringConcatenation _builder = new StringConcatenation(); _builder.append("new Thread [|"); _builder.newLine(); _builder.append("\t"); _builder.append("println(\"foo\")"); _builder.newLine(); _builder.append("]"); _builder.newLine(); it.setExpectation(_builder); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("new Thread[ | println(\"foo\")"); _builder_1.newLine(); _builder_1.append("]"); _builder_1.newLine(); it.setToBeFormatted(_builder_1); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
@Test public void formatSynchronizedBlock_2() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { StringConcatenation _builder = new StringConcatenation(); _builder.append("synchronized (new Object) {"); _builder.newLine(); _builder.append("}"); _builder.newLine(); it.setExpectation(_builder); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("synchronized ( new Object ) { }"); _builder_1.newLine(); it.setToBeFormatted(_builder_1); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
@Test public void formatIf1ML1() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { final Procedure1<MapBasedPreferenceValues> _function_1 = (MapBasedPreferenceValues it_1) -> { it_1.<Boolean>put(XbaseFormatterPreferenceKeys.whitespaceBetweenKeywordAndParenthesisML, Boolean.valueOf(true)); }; it.preferences(_function_1); StringConcatenation _builder = new StringConcatenation(); _builder.append("if (true)"); _builder.newLine(); _builder.append("\t"); _builder.append("println(\"foo\")"); _builder.newLine(); it.setToBeFormatted(_builder); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
@Test public void commentAfterForExpression1() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { StringConcatenation _builder = new StringConcatenation(); _builder.append("for (f : #[])"); _builder.newLine(); _builder.append("\t"); _builder.append("if (1 < 2) {"); _builder.newLine(); _builder.append("\t"); _builder.append("}"); _builder.newLine(); _builder.newLine(); _builder.append("// foo"); _builder.newLine(); _builder.append("var lastOffset = \"\""); _builder.newLine(); it.setToBeFormatted(_builder); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
@Test public void formatIf1MLVar() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { StringConcatenation _builder = new StringConcatenation(); _builder.append("var x = if (true)"); _builder.newLine(); _builder.append("\t\t"); _builder.append("println(\"foo\")"); _builder.newLine(); _builder.append("\t"); _builder.append("else"); _builder.newLine(); _builder.append("\t\t"); _builder.append("println(\"bar\")"); _builder.newLine(); it.setExpectation(_builder); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("var x = if(true)"); _builder_1.newLine(); _builder_1.append("println(\"foo\") else println(\"bar\")"); _builder_1.newLine(); it.setToBeFormatted(_builder_1); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
@Test public void formatEmptySwitchML() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { StringConcatenation _builder = new StringConcatenation(); _builder.append("switch null {"); _builder.newLine(); _builder.append("}"); _builder.newLine(); it.setExpectation(_builder); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("switch null { "); _builder_1.newLine(); _builder_1.append("\t"); _builder_1.newLine(); _builder_1.append("\t"); _builder_1.newLine(); _builder_1.append("\t"); _builder_1.newLine(); _builder_1.append("}"); _builder_1.newLine(); it.setToBeFormatted(_builder_1); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
@Test public void formatIfElse2() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { StringConcatenation _builder = new StringConcatenation(); _builder.append("if (true) {"); _builder.newLine(); _builder.append("\t"); _builder.append("println(\"foo\")"); _builder.newLine(); _builder.append("} else {"); _builder.newLine(); _builder.append("\t"); _builder.append("println(\"bar\")"); _builder.newLine(); _builder.append("}"); _builder.newLine(); it.setToBeFormatted(_builder); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
@Test public void formatFor1() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { StringConcatenation _builder = new StringConcatenation(); _builder.append("for (i : 1 .. 2)"); _builder.newLine(); _builder.append("\t"); _builder.append("println(i)"); _builder.newLine(); it.setExpectation(_builder); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("for ( i : 1 .. 2 ) println(i)"); _builder_1.newLine(); it.setToBeFormatted(_builder_1); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
@Test public void formatBasicFor() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { StringConcatenation _builder = new StringConcatenation(); _builder.append("for (var i = 1; i < 10; i = i + 1)"); _builder.newLine(); _builder.append("\t"); _builder.append("println(i)"); _builder.newLine(); it.setExpectation(_builder); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("for ( var i = 1 ; i < 10; i = i + 1 ) println(i)"); _builder_1.newLine(); it.setToBeFormatted(_builder_1); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
private void assertFormattedTypeRef(final Procedure1<? super FormatterTestRequest> test) { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { test.apply(it); StringConcatenation _builder = new StringConcatenation(); _builder.append("{"); _builder.newLine(); _builder.append("\t"); _builder.append("var "); CharSequence _toBeFormatted = it.getToBeFormatted(); _builder.append(_toBeFormatted, "\t"); _builder.append(" x"); _builder.newLineIfNotEmpty(); _builder.append("}"); _builder.newLine(); it.setToBeFormatted(_builder.toString().trim()); }; this.tester.assertFormatted(_function); }
@Test public void formatBasicFor4() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { StringConcatenation _builder = new StringConcatenation(); _builder.append("val x = 1"); _builder.newLine(); _builder.append("for (; x < 10;)"); _builder.newLine(); _builder.append("\t"); _builder.append("println(x)"); _builder.newLine(); it.setExpectation(_builder); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("val x = 1"); _builder_1.newLine(); _builder_1.append("for ( ; x < 10 ; ) println(x)"); _builder_1.newLine(); it.setToBeFormatted(_builder_1); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
@Test public void formatBasicFor5() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { StringConcatenation _builder = new StringConcatenation(); _builder.append("val x = 1"); _builder.newLine(); _builder.append("for (;; x = x + 1, x = x + 2)"); _builder.newLine(); _builder.append("\t"); _builder.append("println(x)"); _builder.newLine(); it.setExpectation(_builder); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("val x = 1"); _builder_1.newLine(); _builder_1.append("for ( ; ; x = x \t+ 1 , x = x + 2 ) println(x)"); _builder_1.newLine(); it.setToBeFormatted(_builder_1); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
@Test public void commentInIfExpression() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { StringConcatenation _builder = new StringConcatenation(); _builder.append("if (true)"); _builder.newLine(); _builder.append("\t"); _builder.append("println(\"foo\")"); _builder.newLine(); _builder.append("else // if (true)"); _builder.newLine(); _builder.append("\t"); _builder.append("println(\"bar\")"); _builder.newLine(); _builder.append("println(\"end\")"); _builder.newLine(); it.setToBeFormatted(_builder); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
@Test public void formatWhile11() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { final Procedure1<MapBasedPreferenceValues> _function_1 = (MapBasedPreferenceValues it_1) -> { it_1.<Boolean>put(XbaseFormatterPreferenceKeys.whitespaceBetweenKeywordAndParenthesisML, Boolean.valueOf(true)); }; it.preferences(_function_1); StringConcatenation _builder = new StringConcatenation(); _builder.append("while (true)"); _builder.newLine(); _builder.append("\t"); _builder.append("println(\"x\")"); _builder.newLine(); it.setToBeFormatted(_builder); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
@Test public void formatWhile12() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { final Procedure1<MapBasedPreferenceValues> _function_1 = (MapBasedPreferenceValues it_1) -> { it_1.<Boolean>put(XbaseFormatterPreferenceKeys.whitespaceBetweenKeywordAndParenthesisML, Boolean.valueOf(false)); }; it.preferences(_function_1); StringConcatenation _builder = new StringConcatenation(); _builder.append("while(true)"); _builder.newLine(); _builder.append("\t"); _builder.append("println(\"x\")"); _builder.newLine(); it.setToBeFormatted(_builder); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
public void assertFormattedExpression(final Procedure1<? super FormatterTestRequest> test) { String _newLine = Strings.newLine(); final String prefix = ("{" + _newLine); String _newLine_1 = Strings.newLine(); final String postfix = (_newLine_1 + "}"); final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { test.apply(it); final Procedure1<MapBasedPreferenceValues> _function_1 = (MapBasedPreferenceValues it_1) -> { it_1.<Integer>put(FormatterPreferenceKeys.maxLineWidth, Integer.valueOf(80)); }; it.preferences(_function_1); String _indent = this.indent(it.getExpectationOrToBeFormatted().toString().trim(), "\t"); String _plus = (prefix + _indent); String _plus_1 = (_plus + postfix); it.setExpectation(_plus_1); String _indent_1 = this.indent(it.getToBeFormatted().toString().trim(), "\t"); String _plus_2 = (prefix + _indent_1); String _plus_3 = (_plus_2 + postfix); it.setToBeFormatted(_plus_3); }; final Procedure1<? super FormatterTestRequest> setup = _function; this.assertFormatted(((Procedure1<FormatterTestRequest>)setup)); }
@Test public void formatTryCatchExpression2() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { StringConcatenation _builder = new StringConcatenation(); _builder.append("try {"); _builder.newLine(); _builder.append("\t"); _builder.append("println(\"x\")"); _builder.newLine(); _builder.append("} catch (Exception e) {"); _builder.newLine(); _builder.append("\t"); _builder.append("println(\"y\")"); _builder.newLine(); _builder.append("}"); _builder.newLine(); it.setExpectation(_builder); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("try { println(\"x\") } catch ( Exception e ) { println(\"y\") }"); _builder_1.newLine(); it.setToBeFormatted(_builder_1); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
@Test public void formatDoWhile11() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { final Procedure1<MapBasedPreferenceValues> _function_1 = (MapBasedPreferenceValues it_1) -> { it_1.<Boolean>put(XbaseFormatterPreferenceKeys.whitespaceBetweenKeywordAndParenthesisML, Boolean.valueOf(true)); }; it.preferences(_function_1); StringConcatenation _builder = new StringConcatenation(); _builder.append("do"); _builder.newLine(); _builder.append("\t"); _builder.append("println(\"x\")"); _builder.newLine(); _builder.append("while (true)"); _builder.newLine(); it.setToBeFormatted(_builder); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
@Test public void formatDoWhile12() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { final Procedure1<MapBasedPreferenceValues> _function_1 = (MapBasedPreferenceValues it_1) -> { it_1.<Boolean>put(XbaseFormatterPreferenceKeys.whitespaceBetweenKeywordAndParenthesisML, Boolean.valueOf(false)); }; it.preferences(_function_1); StringConcatenation _builder = new StringConcatenation(); _builder.append("do"); _builder.newLine(); _builder.append("\t"); _builder.append("println(\"x\")"); _builder.newLine(); _builder.append("while(true)"); _builder.newLine(); it.setToBeFormatted(_builder); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
@Test public void formatSwitchCaseSL1() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { final Procedure1<MapBasedPreferenceValues> _function_1 = (MapBasedPreferenceValues it_1) -> { it_1.<Boolean>put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(true)); }; it.preferences(_function_1); StringConcatenation _builder = new StringConcatenation(); _builder.append("switch \'x\'"); _builder.newLine(); _builder.append("{"); _builder.newLine(); _builder.append("\t"); _builder.append("case \'x\': println(\'x\')"); _builder.newLine(); _builder.append("\t"); _builder.append("case \'y\': println(\'y\')"); _builder.newLine(); _builder.append("}"); _builder.newLine(); it.setToBeFormatted(_builder); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
@Test public void formatFeatureCall1() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { StringConcatenation _builder = new StringConcatenation(); _builder.append("val ML2 = newArrayList(newArrayList(1, 2, 3, 4, 5, 6),"); _builder.newLine(); _builder.append("\t"); _builder.append("newArrayList(5, 6, 7, 8), newArrayList(9, 10, 11, 12),"); _builder.newLine(); _builder.append("\t"); _builder.append("newArrayList(13, 14, 15, 16))"); _builder.newLine(); it.setExpectation(_builder); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("val ML2 = newArrayList(newArrayList(1, 2, 3, 4, 5, 6), newArrayList(5, 6, 7, 8), newArrayList(9, 10, 11, 12), newArrayList(13, 14, 15, 16))"); _builder_1.newLine(); it.setToBeFormatted(_builder_1); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
@Test public void formatConstructorCall1() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { StringConcatenation _builder = new StringConcatenation(); _builder.append("val ML2 = new ArrayList(new ArrayList(1, 2, 3, 4, 5, 6),"); _builder.newLine(); _builder.append("\t"); _builder.append("new ArrayList(5, 6, 7, 8), new ArrayList(9, 10, 11, 12),"); _builder.newLine(); _builder.append("\t"); _builder.append("new ArrayList(13, 14, 15, 16))"); _builder.newLine(); it.setExpectation(_builder); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("val ML2 = new ArrayList(new ArrayList(1, 2, 3, 4, 5, 6), new ArrayList(5, 6, 7, 8), new ArrayList(9, 10, 11, 12), new ArrayList(13, 14, 15, 16))"); _builder_1.newLine(); it.setToBeFormatted(_builder_1); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
@Test public void formatConstructorCall2() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { StringConcatenation _builder = new StringConcatenation(); _builder.append("val ML2 = new ArrayList(new ArrayList(1, 2, 3, 4),"); _builder.newLine(); _builder.append("\t"); _builder.append("new ArrayList(5, 6, 7, 8, 101, 102, 103, 104, 105, 106, 107, 108, 109,"); _builder.newLine(); _builder.append("\t\t"); _builder.append("110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120),"); _builder.newLine(); _builder.append("\t"); _builder.append("new ArrayList(9, 10, 11, 12), new ArrayList(13, 14, 15, 16))"); _builder.newLine(); it.setExpectation(_builder); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("val ML2 = new ArrayList(new ArrayList(1, 2, 3, 4), new ArrayList(5, 6, 7, 8, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120), new ArrayList(9, 10, 11, 12), new ArrayList(13, 14, 15, 16))"); _builder_1.newLine(); it.setToBeFormatted(_builder_1); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
@Test public void formatTryFinallyExpression2() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { StringConcatenation _builder = new StringConcatenation(); _builder.append("try {"); _builder.newLine(); _builder.append("\t"); _builder.append("println(\"x\")"); _builder.newLine(); _builder.append("} finally {"); _builder.newLine(); _builder.append("\t"); _builder.append("println(\"y\")"); _builder.newLine(); _builder.append("}"); _builder.newLine(); it.setExpectation(_builder); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("try { println(\"x\") } finally { println(\"y\") }"); _builder_1.newLine(); it.setToBeFormatted(_builder_1); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
@Test public void formatMemberFeatureCall2() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { StringConcatenation _builder = new StringConcatenation(); _builder.append("val ML1 = \"x\".substring(0).substring(1)"); _builder.newLine(); it.setExpectation(_builder); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("val ML1 = \"x\""); _builder_1.newLine(); _builder_1.append("."); _builder_1.newLine(); _builder_1.append("substring(0)"); _builder_1.newLine(); _builder_1.append("."); _builder_1.newLine(); _builder_1.append("substring(1)"); _builder_1.newLine(); it.setToBeFormatted(_builder_1); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
@Test public void formatMemberFeatureCall21() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { StringConcatenation _builder = new StringConcatenation(); _builder.append("val ML1 = \"x\".toString.toString"); _builder.newLine(); it.setExpectation(_builder); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("val ML1 = \"x\""); _builder_1.newLine(); _builder_1.append("."); _builder_1.newLine(); _builder_1.append("toString"); _builder_1.newLine(); _builder_1.append("."); _builder_1.newLine(); _builder_1.append("toString"); _builder_1.newLine(); it.setToBeFormatted(_builder_1); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
@Test public void formatMemberFeatureCall3() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { StringConcatenation _builder = new StringConcatenation(); _builder.append("val ML1 = \"x\".substring(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,"); _builder.newLine(); _builder.append("\t"); _builder.append("15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28)"); _builder.newLine(); it.setExpectation(_builder); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("val ML1 = \"x\".substring(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28)"); _builder_1.newLine(); it.setToBeFormatted(_builder_1); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
@Test public void formatMemberFeatureCall4() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { StringConcatenation _builder = new StringConcatenation(); _builder.append("val ML1 = \"x\".substring(0, 1, 2)"); _builder.newLine(); it.setExpectation(_builder); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("val ML1 = \"x\".substring ("); _builder_1.newLine(); _builder_1.newLine(); _builder_1.append("0, "); _builder_1.newLine(); _builder_1.newLine(); _builder_1.append("1, "); _builder_1.newLine(); _builder_1.newLine(); _builder_1.append("2)"); _builder_1.newLine(); it.setToBeFormatted(_builder_1); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
@Test public void formatMemberFeatureCallBuilderMultiline1() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { StringConcatenation _builder = new StringConcatenation(); _builder.append("newArrayList(\"x\").map("); _builder.newLine(); _builder.append("\t"); _builder.append("length"); _builder.newLine(); _builder.append(")[lenght]"); _builder.newLine(); it.setExpectation(_builder); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("newArrayList(\"x\") . map ( length "); _builder_1.newLine(); _builder_1.append(") [ lenght ]"); _builder_1.newLine(); it.setToBeFormatted(_builder_1); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
@Test public void formatMemberFeatureCallBuilderMultiline2() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { StringConcatenation _builder = new StringConcatenation(); _builder.append("newArrayList(\"x\").map(length) ["); _builder.newLine(); _builder.append("\t"); _builder.append("length"); _builder.newLine(); _builder.append("]"); _builder.newLine(); it.setExpectation(_builder); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("newArrayList(\"x\") . map ( length ) [ length "); _builder_1.newLine(); _builder_1.append("]"); _builder_1.newLine(); it.setToBeFormatted(_builder_1); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
@Test public void formatBinaryExpression1() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { StringConcatenation _builder = new StringConcatenation(); _builder.append("val ML1 = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 +"); _builder.newLine(); _builder.append("\t"); _builder.append("16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 +"); _builder.newLine(); _builder.append("\t"); _builder.append("30 + 31 + 32 + 33 + 34 + 35 + 36"); _builder.newLine(); it.setExpectation(_builder); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("val ML1 = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 "); _builder_1.newLine(); it.setToBeFormatted(_builder_1); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
public void assertFormatted(FormatterTestRequest req) { checkNotNull(req); checkNotNull(req.getToBeFormatted()); FormatterRequest request = req.getRequest(); checkArgument(request.getTextRegionAccess() == null); String document = req.getToBeFormatted().toString(); XtextResource parsed = parse(document); if (req.isAllowSyntaxErrors()) { request.setExceptionHandler(ExceptionAcceptor.IGNORING); } else { assertNoSyntaxErrors(parsed); request.setExceptionHandler(ExceptionAcceptor.THROWING); } request.setTextRegionAccess(createRegionAccess(parsed, req)); if (request.getPreferences() == null) request.setPreferences(new MapBasedPreferenceValues(Maps.<String, String> newLinkedHashMap())); List<ITextReplacement> replacements = createFormatter(req).format(request); assertReplacementsAreInRegion(replacements, request.getRegions(), document); if (!req.isAllowUnformattedWhitespace()) assertAllWhitespaceIsFormatted(request.getTextRegionAccess(), replacements); String formatted = request.getTextRegionAccess().getRewriter().renderToString(replacements); Assert.assertEquals(req.getExpectationOrToBeFormatted().toString(), formatted); // TODO: assert formatting a second time only produces identity replacements // TODO: assert formatting with undefined whitespace only }
@Test public void formatGenerics() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { StringConcatenation _builder = new StringConcatenation(); _builder.append("val x = <Pair<String, String>>newArrayList()"); _builder.newLine(); it.setToBeFormatted(_builder); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
@Test public void formatTryCatchCatchFinallyExpression2() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { StringConcatenation _builder = new StringConcatenation(); _builder.append("try {"); _builder.newLine(); _builder.append("\t"); _builder.append("println(\"x\")"); _builder.newLine(); _builder.append("} catch (Exception e) {"); _builder.newLine(); _builder.append("\t"); _builder.append("println(\"y\")"); _builder.newLine(); _builder.append("} catch (Exception f) {"); _builder.newLine(); _builder.append("\t"); _builder.append("println(\"z\")"); _builder.newLine(); _builder.append("} finally {"); _builder.newLine(); _builder.append("\t"); _builder.append("println(\"a\")"); _builder.newLine(); _builder.append("}"); _builder.newLine(); it.setExpectation(_builder); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("try { println(\"x\") } catch ( Exception e ) { println(\"y\") } catch ( Exception f ) { println(\"z\") } finally { println(\"a\") }"); _builder_1.newLine(); it.setToBeFormatted(_builder_1); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
@Test public void formatClosures() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { StringConcatenation _builder = new StringConcatenation(); _builder.append("val x = newArrayList(\"A\", \"b\")"); _builder.newLine(); _builder.append("val y = x.filter[toUpperCase == it]"); _builder.newLine(); _builder.append("y.join"); _builder.newLine(); it.setToBeFormatted(_builder); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
@Test public void formatClosuresParenthesis() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { StringConcatenation _builder = new StringConcatenation(); _builder.append("val x = newArrayList(\"A\", \"b\")"); _builder.newLine(); _builder.append("val y = x.filter(toUpperCase == it)"); _builder.newLine(); _builder.append("y.join"); _builder.newLine(); it.setToBeFormatted(_builder); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
@Test public void formatClosuresParenthesis2() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { StringConcatenation _builder = new StringConcatenation(); _builder.append("val x = newArrayList(\"A\", \"b\")"); _builder.newLine(); _builder.append("val y = x.filter(foo|foo.toUpperCase == foo)"); _builder.newLine(); _builder.append("y.join"); _builder.newLine(); it.setToBeFormatted(_builder); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
@Test public void formatXReturnExpression1() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { StringConcatenation _builder = new StringConcatenation(); _builder.append("return \"foo\""); _builder.newLine(); it.setExpectation(_builder); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("return \"foo\""); _builder_1.newLine(); it.setToBeFormatted(_builder_1); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }