Search in sources :

Example 6 with XBooleanLiteral

use of org.eclipse.xtext.xbase.XBooleanLiteral in project xtext-xtend by eclipse.

the class ReorderedVarArgFeatureCallArgumentsTest method testBug457779_01.

@Test
public void testBug457779_01() {
    final IFeatureCallArguments arguments = this.toArgumentsWithReceiver("String s, boolean b, int[] i", "[], 1, [1], true");
    final XExpression first = arguments.getArgument(0);
    Assert.assertNull(first);
    final LightweightTypeReference firstType = arguments.getDeclaredTypeForLambda(0);
    Assert.assertNull(firstType);
    final XExpression second = arguments.getArgument(1);
    Assert.assertTrue((second instanceof XNumberLiteral));
    final LightweightTypeReference secondType = arguments.getDeclaredTypeForLambda(1);
    Assert.assertEquals("boolean", secondType.getSimpleName());
    final XExpression third = arguments.getArgument(2);
    Assert.assertTrue((third instanceof XClosure));
    XExpression _expression = ((XClosure) third).getExpression();
    Assert.assertFalse(((XBlockExpression) _expression).getExpressions().isEmpty());
    final LightweightTypeReference thirdType = arguments.getDeclaredTypeForLambda(2);
    Assert.assertEquals("int", thirdType.getSimpleName());
    final XExpression fourth = arguments.getArgument(3);
    Assert.assertTrue((fourth instanceof XBooleanLiteral));
    final LightweightTypeReference fourthType = arguments.getDeclaredTypeForLambda(3);
    Assert.assertEquals("int", fourthType.getSimpleName());
    final XExpression fifth = arguments.getArgument(4);
    Assert.assertTrue((fifth instanceof XClosure));
    XExpression _expression_1 = ((XClosure) fifth).getExpression();
    Assert.assertTrue(((XBlockExpression) _expression_1).getExpressions().isEmpty());
    final LightweightTypeReference fifthType = arguments.getDeclaredTypeForLambda(4);
    Assert.assertEquals("String", fifthType.getSimpleName());
    try {
        arguments.getArgument(5);
        Assert.fail("Expected exception");
    } catch (final Throwable _t) {
        if (_t instanceof IndexOutOfBoundsException) {
        } else {
            throw Exceptions.sneakyThrow(_t);
        }
    }
    try {
        arguments.getDeclaredTypeForLambda(5);
        Assert.fail("Expected exception");
    } catch (final Throwable _t_1) {
        if (_t_1 instanceof IndexOutOfBoundsException) {
        } else {
            throw Exceptions.sneakyThrow(_t_1);
        }
    }
}
Also used : XBlockExpression(org.eclipse.xtext.xbase.XBlockExpression) XBooleanLiteral(org.eclipse.xtext.xbase.XBooleanLiteral) LightweightTypeReference(org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference) XClosure(org.eclipse.xtext.xbase.XClosure) XExpression(org.eclipse.xtext.xbase.XExpression) XNumberLiteral(org.eclipse.xtext.xbase.XNumberLiteral) IFeatureCallArguments(org.eclipse.xtext.xbase.typesystem.arguments.IFeatureCallArguments) Test(org.junit.Test)

Aggregations

XBooleanLiteral (org.eclipse.xtext.xbase.XBooleanLiteral)6 Test (org.junit.Test)5 XNumberLiteral (org.eclipse.xtext.xbase.XNumberLiteral)4 RichString (org.eclipse.xtend.core.xtend.RichString)3 RichStringLiteral (org.eclipse.xtend.core.xtend.RichStringLiteral)3 XExpression (org.eclipse.xtext.xbase.XExpression)3 XStringLiteral (org.eclipse.xtext.xbase.XStringLiteral)3 IFeatureCallArguments (org.eclipse.xtext.xbase.typesystem.arguments.IFeatureCallArguments)3 LightweightTypeReference (org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference)3 RichStringIf (org.eclipse.xtend.core.xtend.RichStringIf)2 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)2 XBinaryOperation (org.eclipse.xtext.xbase.XBinaryOperation)2 XBlockExpression (org.eclipse.xtext.xbase.XBlockExpression)2 XClosure (org.eclipse.xtext.xbase.XClosure)2 EPackage (org.eclipse.emf.ecore.EPackage)1 RichStringElseIf (org.eclipse.xtend.core.xtend.RichStringElseIf)1 XtendAnnotationType (org.eclipse.xtend.core.xtend.XtendAnnotationType)1 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)1 XtendEnum (org.eclipse.xtend.core.xtend.XtendEnum)1 XtendField (org.eclipse.xtend.core.xtend.XtendField)1