use of org.eclipse.xtend.core.xtend.RichStringLiteral in project xtext-xtend by eclipse.
the class ParserTest method testRichStringWithComment_01.
@Test
public void testRichStringWithComment_01() throws Exception {
XtendFunction function = function("def foo() '''first� /* ml comment\n */ �� sl_comment \nsecond'''");
assertTrue(function.getExpression() instanceof RichString);
RichString richString = (RichString) function.getExpression();
assertEquals(2, richString.getExpressions().size());
RichStringLiteral first = (RichStringLiteral) richString.getExpressions().get(0);
assertEquals("first", first.getValue());
RichStringLiteral second = (RichStringLiteral) richString.getExpressions().get(1);
assertEquals("second", second.getValue());
}
use of org.eclipse.xtend.core.xtend.RichStringLiteral in project xtext-xtend by eclipse.
the class ParserTest method testRichStringWithComment_00.
@Test
public void testRichStringWithComment_00() throws Exception {
XtendFunction function = function("def foo() '''first��� comment \nsecond'''");
assertTrue(function.getExpression() instanceof RichString);
RichString richString = (RichString) function.getExpression();
assertEquals(2, richString.getExpressions().size());
RichStringLiteral first = (RichStringLiteral) richString.getExpressions().get(0);
assertEquals("first", first.getValue());
RichStringLiteral second = (RichStringLiteral) richString.getExpressions().get(1);
assertEquals("second", second.getValue());
}
use of org.eclipse.xtend.core.xtend.RichStringLiteral in project xtext-xtend by eclipse.
the class ParserTest method testRichStringIF_01.
@Test
public void testRichStringIF_01() throws Exception {
XtendFunction function = function("def foo() ''' foo �IF true� wurst �IF false� brot �ELSE� machine �ENDIF� bar �ENDIF�'''");
final RichString richString = (RichString) function.getExpression();
assertTrue(richString.getExpressions().get(0) instanceof RichStringLiteral);
final RichStringIf rsIf = (RichStringIf) richString.getExpressions().get(1);
assertTrue(rsIf.getIf() instanceof XBooleanLiteral);
final RichString then = (RichString) rsIf.getThen();
assertEquals(3, then.getExpressions().size());
RichStringIf innerIf = (RichStringIf) then.getExpressions().get(1);
assertTrue(innerIf.getIf() instanceof XBooleanLiteral);
assertTrue(innerIf.getElse() instanceof RichString);
assertTrue(rsIf.getElse() == null);
assertTrue(richString.getExpressions().get(2) instanceof RichStringLiteral);
}
use of org.eclipse.xtend.core.xtend.RichStringLiteral in project xtext-xtend by eclipse.
the class ParserTest method testRichString_01.
@Test
public void testRichString_01() throws Exception {
XtendFunction function = function("def foo() ''' foo �'holla'� bar '''");
final RichString richString = (RichString) function.getExpression();
assertTrue(richString.getExpressions().get(0) instanceof RichStringLiteral);
assertTrue(richString.getExpressions().get(1) instanceof XStringLiteral);
assertTrue(richString.getExpressions().get(2) instanceof RichStringLiteral);
}
use of org.eclipse.xtend.core.xtend.RichStringLiteral in project xtext-xtend by eclipse.
the class ParserTest method testRichStringFOR_03.
@Test
public void testRichStringFOR_03() throws Exception {
XtendFunction function = function("def withForLoop(String it) '''�it��val it = 1..10��FOR i: it SEPARATOR it��ENDFOR�'''");
final RichString richString = (RichString) function.getExpression();
assertTrue(richString.getExpressions().get(0) instanceof RichStringLiteral);
assertTrue(richString.getExpressions().get(1) instanceof XFeatureCall);
JvmOperation operation = associations.getDirectlyInferredOperation(function);
assertSame(operation.getParameters().get(0), ((XAbstractFeatureCall) richString.getExpressions().get(1)).getFeature());
assertTrue(richString.getExpressions().get(2) instanceof RichStringLiteral);
assertTrue(richString.getExpressions().get(3) instanceof XVariableDeclaration);
assertTrue(richString.getExpressions().get(4) instanceof RichStringLiteral);
assertTrue(richString.getExpressions().get(5) instanceof RichStringForLoop);
final RichStringForLoop rsFor = (RichStringForLoop) richString.getExpressions().get(5);
assertTrue(rsFor.getForExpression() instanceof XFeatureCall);
assertSame(richString.getExpressions().get(3), ((XAbstractFeatureCall) rsFor.getForExpression()).getFeature());
assertEquals("i", rsFor.getDeclaredParam().getName());
assertTrue(rsFor.getSeparator() instanceof XFeatureCall);
assertSame(richString.getExpressions().get(3), ((XAbstractFeatureCall) rsFor.getSeparator()).getFeature());
}
Aggregations