Java Code Examples for org.eclipse.xtext.testing.formatter.FormatterTestRequest#setExpectation()
The following examples show how to use
org.eclipse.xtext.testing.formatter.FormatterTestRequest#setExpectation() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XbaseFormatterTest.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@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); }
Example 2
Source File: XbaseFormatterTest.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@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); }
Example 3
Source File: XbaseFormatterTest.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Test public void formatClosuresEmpty() { 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[]"); _builder.newLine(); _builder.append("y.join"); _builder.newLine(); it.setExpectation(_builder); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("val x = newArrayList(\"A\", \"b\") val y = x.filter[ ] y.join"); _builder_1.newLine(); it.setToBeFormatted(_builder_1); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
Example 4
Source File: XbaseFormatterTest.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@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); }
Example 5
Source File: XbaseFormatterTest.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Test public void formatBinaryExpression2() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { StringConcatenation _builder = new StringConcatenation(); _builder.append("val ML1 = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 +"); _builder.newLine(); _builder.append("\t"); _builder.append("11 * 12 * 13 * 14 * 15 * 16 * 17 * 18 + 19 + 20 + 21 + 22 + 23 + 24 +"); _builder.newLine(); _builder.append("\t"); _builder.append("25 + 26 + 27 + 28 + 29 + 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); }
Example 6
Source File: XbaseFormatterTest.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Test public void formatIf1MLSemicolon2() { 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("println(\"bar\")"); _builder.newLine(); it.setExpectation(_builder); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("if(true)"); _builder_1.newLine(); _builder_1.append("println(\"foo\");"); _builder_1.newLine(); _builder_1.append("println(\"bar\")"); _builder_1.newLine(); it.setToBeFormatted(_builder_1); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
Example 7
Source File: XbaseFormatterTest.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@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); }
Example 8
Source File: XbaseFormatterTest.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@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); }
Example 9
Source File: XbaseFormatterTest.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@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); }
Example 10
Source File: XbaseFormatterTest.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@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); }
Example 11
Source File: XbaseFormatterTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Test public void formatSwitchCaseSLParenthesis() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { StringConcatenation _builder = new StringConcatenation(); _builder.append("switch \'x\' {"); _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.setExpectation(_builder); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("switch \'x\' { "); _builder_1.newLine(); _builder_1.append("\t"); _builder_1.append("case \'x\': println(\'x\') case \'y\': println(\'y\')"); _builder_1.newLine(); _builder_1.append("}"); _builder_1.newLine(); it.setToBeFormatted(_builder_1); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
Example 12
Source File: XbaseFormatterTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Test public void formatIfElse1ML() { 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(); it.setExpectation(_builder); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("if(true)"); _builder_1.newLine(); _builder_1.append("println(\"foo\")"); _builder_1.newLine(); _builder_1.append("else"); _builder_1.newLine(); _builder_1.append("println(\"bar\")"); _builder_1.newLine(); it.setToBeFormatted(_builder_1); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
Example 13
Source File: XbaseFormatterTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@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); }
Example 14
Source File: XbaseFormatterTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Test public void formatListLiteral1() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { StringConcatenation _builder = new StringConcatenation(); _builder.append("#[12, 13, 14]"); _builder.newLine(); it.setExpectation(_builder); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("#[12, 13 ,\t14\t\t]"); _builder_1.newLine(); it.setToBeFormatted(_builder_1); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
Example 15
Source File: XbaseFormatterTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Test public void formatTryCatchFinallyExpression1() { 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("finally"); _builder.newLine(); _builder.append("\t"); _builder.append("println(\"z\")"); _builder.newLine(); it.setExpectation(_builder); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("try println(\"x\") catch ( Exception e ) println(\"y\") finally println(\"z\")"); _builder_1.newLine(); it.setToBeFormatted(_builder_1); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
Example 16
Source File: XbaseFormatterTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Test public void formatMemberFeatureCallBuilder1() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { StringConcatenation _builder = new StringConcatenation(); _builder.append("newArrayList(\"x\").map()[]"); _builder.newLine(); it.setExpectation(_builder); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("newArrayList(\"x\") . map ( ) [ ]"); _builder_1.newLine(); it.setToBeFormatted(_builder_1); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
Example 17
Source File: XbaseFormatterTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Test public void formatIfElseIf2() { 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 (false) {"); _builder.newLine(); _builder.append("\t"); _builder.append("println(\"bar\")"); _builder.newLine(); _builder.append("}"); _builder.newLine(); it.setExpectation(_builder); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("if(true) {"); _builder_1.newLine(); _builder_1.append("println(\"foo\")"); _builder_1.newLine(); _builder_1.append("} else if(false) {"); _builder_1.newLine(); _builder_1.append("println(\"bar\")"); _builder_1.newLine(); _builder_1.append("}"); _builder_1.newLine(); it.setToBeFormatted(_builder_1); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
Example 18
Source File: XbaseFormatterTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Test public void formatClosuresMultiLine() { 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 ["); _builder.newLine(); _builder.append("\t"); _builder.append("val z = it"); _builder.newLine(); _builder.append("\t"); _builder.append("z.toUpperCase == z"); _builder.newLine(); _builder.append("]"); _builder.newLine(); _builder.append("y.join"); _builder.newLine(); it.setExpectation(_builder); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("val x = newArrayList(\"A\", \"b\") val y = x.filter ["); _builder_1.newLine(); _builder_1.append("\t"); _builder_1.append("val z = it z.toUpperCase == z "); _builder_1.newLine(); _builder_1.append("] y.join"); _builder_1.newLine(); it.setToBeFormatted(_builder_1); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
Example 19
Source File: XbaseFormatterTest.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
@Test public void formatSwitchMLBlock1() { 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\':"); _builder.newLine(); _builder.append("\t"); _builder.append("{"); _builder.newLine(); _builder.append("\t\t"); _builder.append("println(\'x\')"); _builder.newLine(); _builder.append("\t"); _builder.append("}"); _builder.newLine(); _builder.append("\t"); _builder.append("case \'y\':"); _builder.newLine(); _builder.append("\t"); _builder.append("{"); _builder.newLine(); _builder.append("\t\t"); _builder.append("println(\'y\')"); _builder.newLine(); _builder.append("\t"); _builder.append("}"); _builder.newLine(); _builder.append("}"); _builder.newLine(); it.setExpectation(_builder); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("switch \'x\' { case \'x\': { println(\'x\') } case \'y\': { println(\'y\') } }"); _builder_1.newLine(); it.setToBeFormatted(_builder_1); }; this._xbaseFormatterTester.assertFormattedExpression(_function); }
Example 20
Source File: StatemachineFormatterTest.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
@Test public void events_resetEvents_commands_state() { final Procedure1<FormatterTestRequest> _function = (FormatterTestRequest it) -> { StringConcatenation _builder = new StringConcatenation(); _builder.append("events doorClosed D1CL drawerOpened D2OP lightOn L1ON doorOpened D1OP panelClosed PNCL end"); _builder.newLine(); _builder.append("resetEvents doorOpened end"); _builder.newLine(); _builder.append("commands unlockPanel PNUL lockPanel NLK lockDoor D1LK unlockDoor D1UL end"); _builder.newLine(); _builder.append("state idle actions {unlockDoor lockPanel} doorClosed => active end"); _builder.newLine(); it.setToBeFormatted(_builder); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("events"); _builder_1.newLine(); _builder_1.append("\t"); _builder_1.append("doorClosed D1CL"); _builder_1.newLine(); _builder_1.append("\t"); _builder_1.append("drawerOpened D2OP"); _builder_1.newLine(); _builder_1.append("\t"); _builder_1.append("lightOn L1ON"); _builder_1.newLine(); _builder_1.append("\t"); _builder_1.append("doorOpened D1OP"); _builder_1.newLine(); _builder_1.append("\t"); _builder_1.append("panelClosed PNCL"); _builder_1.newLine(); _builder_1.append("end"); _builder_1.newLine(); _builder_1.newLine(); _builder_1.append("resetEvents"); _builder_1.newLine(); _builder_1.append("\t"); _builder_1.append("doorOpened"); _builder_1.newLine(); _builder_1.append("end"); _builder_1.newLine(); _builder_1.newLine(); _builder_1.append("commands"); _builder_1.newLine(); _builder_1.append("\t"); _builder_1.append("unlockPanel PNUL"); _builder_1.newLine(); _builder_1.append("\t"); _builder_1.append("lockPanel NLK"); _builder_1.newLine(); _builder_1.append("\t"); _builder_1.append("lockDoor D1LK"); _builder_1.newLine(); _builder_1.append("\t"); _builder_1.append("unlockDoor D1UL"); _builder_1.newLine(); _builder_1.append("end"); _builder_1.newLine(); _builder_1.newLine(); _builder_1.append("state idle"); _builder_1.newLine(); _builder_1.append("\t"); _builder_1.append("actions {unlockDoor lockPanel}"); _builder_1.newLine(); _builder_1.append("\t"); _builder_1.append("doorClosed => active"); _builder_1.newLine(); _builder_1.append("end"); _builder_1.newLine(); it.setExpectation(_builder_1); }; this._formatterTestHelper.assertFormatted(_function); }