use of org.eclipse.xtext.xbase.XStringLiteral in project xtext-xtend by eclipse.
the class StandardFeatureCallArgumentsTest method test_09.
@Test
public void test_09() {
final IFeatureCallArguments arguments = this.toArgumentsWithoutReceiver("String s", "\"\", 1");
Assert.assertTrue(arguments.hasUnprocessedArguments());
Assert.assertEquals(2, arguments.getArgumentCount());
final IFeatureCallArgumentSlot valid = arguments.getNextUnprocessedArgumentSlot();
Assert.assertFalse(valid.isVarArg());
Assert.assertFalse(valid.isSuperfluous());
XExpression _argumentExpression = valid.getArgumentExpression();
Assert.assertTrue((_argumentExpression instanceof XStringLiteral));
Assert.assertEquals("String", valid.getDeclaredType().getSimpleName());
valid.markProcessed();
Assert.assertTrue(arguments.hasUnprocessedArguments());
final IFeatureCallArgumentSlot superfluous = arguments.getNextUnprocessedArgumentSlot();
Assert.assertFalse(superfluous.isVarArg());
Assert.assertTrue(superfluous.isSuperfluous());
XExpression _argumentExpression_1 = superfluous.getArgumentExpression();
Assert.assertTrue((_argumentExpression_1 instanceof XNumberLiteral));
Assert.assertFalse(arguments.isProcessed(1));
superfluous.markProcessed();
Assert.assertTrue(arguments.isProcessed(1));
Assert.assertFalse(arguments.hasUnprocessedArguments());
}
use of org.eclipse.xtext.xbase.XStringLiteral in project xtext-xtend by eclipse.
the class VarArgFeatureCallArgumentsTest method test_04.
@Test
public void test_04() {
final IFeatureCallArguments arguments = this.toArgumentsWithoutReceiver("String s, int i", "\"\", 1");
Assert.assertEquals(2, arguments.getArgumentCount());
Assert.assertTrue(arguments.hasUnprocessedArguments());
final IFeatureCallArgumentSlot firstSlot = arguments.getNextUnprocessedArgumentSlot();
Assert.assertFalse(firstSlot.isVarArg());
Assert.assertFalse(firstSlot.isSuperfluous());
XExpression _argumentExpression = firstSlot.getArgumentExpression();
Assert.assertTrue((_argumentExpression instanceof XStringLiteral));
Assert.assertEquals("String", firstSlot.getDeclaredType().getSimpleName());
Assert.assertFalse(arguments.isProcessed(0));
firstSlot.markProcessed();
Assert.assertTrue(arguments.isProcessed(0));
Assert.assertTrue(arguments.hasUnprocessedArguments());
final IFeatureCallArgumentSlot secondSlot = arguments.getNextUnprocessedArgumentSlot();
Assert.assertTrue(secondSlot.isVarArg());
Assert.assertFalse(secondSlot.isSuperfluous());
XExpression _argumentExpression_1 = secondSlot.getArgumentExpression();
Assert.assertTrue((_argumentExpression_1 instanceof XNumberLiteral));
Assert.assertEquals("int", secondSlot.getDeclaredType().getSimpleName());
Assert.assertFalse(arguments.isProcessed(1));
secondSlot.markProcessed();
Assert.assertTrue(arguments.isProcessed(1));
Assert.assertFalse(arguments.hasUnprocessedArguments());
}
use of org.eclipse.xtext.xbase.XStringLiteral in project xtext-xtend by eclipse.
the class VarArgFeatureCallArgumentsTest method test_09.
@Test
public void test_09() {
final IFeatureCallArguments arguments = this.toArgumentsWithoutReceiver("String s", "\"\", 1");
Assert.assertTrue(arguments.hasUnprocessedArguments());
Assert.assertEquals(2, arguments.getArgumentCount());
final IFeatureCallArgumentSlot valid = arguments.getNextUnprocessedArgumentSlot();
Assert.assertTrue(valid.isVarArg());
Assert.assertFalse(valid.isSuperfluous());
final List<XExpression> expressions = valid.getArgumentExpressions();
Assert.assertEquals(2, expressions.size());
XExpression _head = IterableExtensions.<XExpression>head(expressions);
Assert.assertTrue((_head instanceof XStringLiteral));
XExpression _last = IterableExtensions.<XExpression>last(expressions);
Assert.assertTrue((_last instanceof XNumberLiteral));
valid.markProcessed();
Assert.assertTrue(arguments.isProcessed(0));
Assert.assertTrue(arguments.isProcessed(1));
Assert.assertFalse(arguments.hasUnprocessedArguments());
}
use of org.eclipse.xtext.xbase.XStringLiteral in project xtext-xtend by eclipse.
the class VarArgFeatureCallArgumentsTest method testBug457779_02.
@Test
public void testBug457779_02() {
final IFeatureCallArguments arguments = this.toArgumentsWithReceiver("String s, int[] i", "\"\", 1");
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 XStringLiteral));
final LightweightTypeReference secondType = arguments.getDeclaredTypeForLambda(1);
Assert.assertEquals("String", secondType.getSimpleName());
final XExpression third = arguments.getArgument(2);
Assert.assertTrue((third instanceof XNumberLiteral));
final LightweightTypeReference thirdType = arguments.getDeclaredTypeForLambda(2);
Assert.assertEquals("int", thirdType.getSimpleName());
try {
arguments.getArgument(3);
Assert.fail("Expected exception");
} catch (final Throwable _t) {
if (_t instanceof IndexOutOfBoundsException) {
} else {
throw Exceptions.sneakyThrow(_t);
}
}
try {
arguments.getDeclaredTypeForLambda(3);
Assert.fail("Expected exception");
} catch (final Throwable _t_1) {
if (_t_1 instanceof IndexOutOfBoundsException) {
} else {
throw Exceptions.sneakyThrow(_t_1);
}
}
}
use of org.eclipse.xtext.xbase.XStringLiteral in project xtext-xtend by eclipse.
the class ValueConverterExceptionProducesErrorTest method testInvalidUnicode.
/**
* see https://bugs.eclipse.org/bugs/show_bug.cgi?id=428525
*/
@Test
public void testInvalidUnicode() throws Exception {
final Resource resource = this.toResource("class C { def m() {\'\\u\'.toString}}");
EcoreUtil2.resolveAll(resource);
Assert.assertEquals(1, resource.getErrors().size());
final Resource.Diagnostic error = IterableExtensions.<Resource.Diagnostic>head(resource.getErrors());
Assert.assertNotNull(error);
Assert.assertEquals("Invalid unicode", error.getMessage());
final XStringLiteral literal = IteratorExtensions.<XStringLiteral>head(Iterators.<XStringLiteral>filter(resource.getAllContents(), XStringLiteral.class));
Assert.assertEquals("u", literal.getValue());
}
Aggregations