@Test public void testDuplicateCases_double_2() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("switch x : 1.5d {"); _builder.newLine(); _builder.append("\t"); _builder.append("case 1.5d: 1"); _builder.newLine(); _builder.append("\t"); _builder.append("case 1.5d: 1"); _builder.newLine(); _builder.append("}"); _builder.newLine(); this._validationTestHelper.assertError(this.expression(_builder), XbasePackage.Literals.XNUMBER_LITERAL, IssueCodes.DUPLICATE_CASE); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
protected static void _privk3_main(final StateMachineAspectStateMachineAspectProperties _self_, final StateMachine _self) { try { while ((!StateMachineAspect.unprocessedString(_self).isEmpty())) { StateAspect.step(StateMachineAspect.currentState(_self), StateMachineAspect.unprocessedString(_self)); } } catch (final Throwable _t) { if (_t instanceof Exception) { final Exception nt = (Exception)_t; String _message = nt.getMessage(); String _plus = ("Stopped due to " + _message); InputOutput.<String>println(_plus); } else { throw Exceptions.sneakyThrow(_t); } } String _unprocessedString = StateMachineAspect.unprocessedString(_self); String _plus_1 = ("unprocessed string: " + _unprocessedString); InputOutput.<String>println(_plus_1); String _consummedString = StateMachineAspect.consummedString(_self); String _plus_2 = ("processed string: " + _consummedString); InputOutput.<String>println(_plus_2); String _producedString = StateMachineAspect.producedString(_self); String _plus_3 = ("produced string: " + _producedString); InputOutput.<String>println(_plus_3); }
protected static void _privk3_step(final StateAspectStateAspectProperties _self_, final State _self, final String inputString) { try { final Function1<Transition, Boolean> _function = (Transition t) -> { return Boolean.valueOf(inputString.startsWith(t.getInput())); }; final Iterable<Transition> validTransitions = IterableExtensions.<Transition>filter(_self.getOutgoingTransitions(), _function); boolean _isEmpty = IterableExtensions.isEmpty(validTransitions); if (_isEmpty) { throw new Exception("No Transition"); } int _size = IterableExtensions.size(validTransitions); boolean _greaterThan = (_size > 1); if (_greaterThan) { throw new Exception("Non Determinism"); } TransitionAspect.fire(((Transition[])Conversions.unwrapArray(validTransitions, Transition.class))[0]); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Check public void checkFecha(final Restaurante restaurante) { try { SimpleDateFormat formateadorFecha = new SimpleDateFormat("dd-MM-yyyy"); Date fechaDada = formateadorFecha.parse(restaurante.getFecha()); Calendar fechaActual = Calendar.getInstance(); Date _time = fechaActual.getTime(); boolean _greaterThan = (fechaDada.compareTo(_time) > 0); if (_greaterThan) { this.error("La fecha tiene que ser igual o menor que la actual", RestaurantePackage.Literals.RESTAURANTE__FECHA, RestauranteValidator.FECHA_INVALIDA); } } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void testUnreachableCatchClause_4() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("try {"); _builder.newLine(); _builder.append("\t"); _builder.newLine(); _builder.append("} catch (java.io.FileNotFoundException e) {"); _builder.newLine(); _builder.append("\t"); _builder.newLine(); _builder.append("} catch (java.io.IOException e) {"); _builder.newLine(); _builder.newLine(); _builder.append("} catch (Exception e) {"); _builder.newLine(); _builder.append("\t"); _builder.newLine(); _builder.append("}"); _builder.newLine(); this._validationTestHelper.assertNoErrors(this.expression(_builder)); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void testUnloadAndGetContents() throws IOException { try { this.with(OptionalEmptyTestLanguageStandaloneSetup.class); Bug451668Test.TestResource r = this.<Bug451668Test.TestResource>get(Bug451668Test.TestResource.class); r.setURI(URI.createURI("foo.dummy")); StringInputStream _stringInputStream = new StringInputStream(""); r.load(_stringInputStream, null); Assert.assertTrue(r.isLoaded()); final int callsBeforeUnload = r.contentsCalls; r.unload(); Assert.assertEquals(callsBeforeUnload, r.contentsCalls); Assert.assertFalse(r.isLoaded()); Assert.assertNull(r.getParseResult()); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
public BooleanResult getBooleanConstantOrNull(final XExpression it) { try { final EvaluationResult evaluationResult = this.doEvaluate(it, this.newEvaluationContext()); Object _rawValue = evaluationResult.getRawValue(); if ((_rawValue instanceof Boolean)) { Object _rawValue_1 = evaluationResult.getRawValue(); boolean _isCompileTimeConstant = evaluationResult.isCompileTimeConstant(); return new BooleanResult(((Boolean) _rawValue_1), _isCompileTimeConstant); } return null; } catch (final Throwable _t) { if (_t instanceof ConstantExpressionEvaluationException) { return null; } else if (_t instanceof IllegalArgumentException) { return null; } else { throw Exceptions.sneakyThrow(_t); } } }
@Test public void testSetLiteralAssignedToCollectionBug498779() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("{"); _builder.newLine(); _builder.append("\t"); _builder.append("val java.util.Collection<String> set = #{\"\"}"); _builder.newLine(); _builder.append("}"); _builder.newLine(); this._validationTestHelper.assertNoErrors(this.expression(_builder)); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void testIncompleteCasesOnEnum_9() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("{"); _builder.newLine(); _builder.append("\t"); _builder.append("switch Object x : org.eclipse.xtext.xbase.tests.validation.Color.RED {"); _builder.newLine(); _builder.append("\t"); _builder.append("}"); _builder.newLine(); _builder.append("}"); _builder.newLine(); this._validationTestHelper.assertNoIssue(this.expression(_builder), XbasePackage.Literals.XMEMBER_FEATURE_CALL, IssueCodes.INCOMPLETE_CASES_ON_ENUM); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
protected Map<String, List<Diagnostic>> getDiagnostics() { try { final Function1<CancelIndicator, HashMap<String, List<Diagnostic>>> _function = (CancelIndicator it) -> { final HashMap<String, List<Diagnostic>> result = CollectionLiterals.<String, List<Diagnostic>>newHashMap(); final Function1<Pair<String, Object>, Object> _function_1 = (Pair<String, Object> it_1) -> { return it_1.getValue(); }; Iterable<PublishDiagnosticsParams> _filter = Iterables.<PublishDiagnosticsParams>filter(ListExtensions.<Pair<String, Object>, Object>map(this.notifications, _function_1), PublishDiagnosticsParams.class); for (final PublishDiagnosticsParams diagnostic : _filter) { result.put(diagnostic.getUri(), diagnostic.getDiagnostics()); } return result; }; return this.languageServer.getRequestManager().<HashMap<String, List<Diagnostic>>>runRead(_function).get(); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Override public void load(final Map<?, ?> options) throws IOException { if (((((!this.isLoaded) && (!this.isLoading)) && (this.resourceStorageFacade != null)) && this.resourceStorageFacade.shouldLoadFromStorage(this))) { boolean _isDebugEnabled = StorageAwareResource.LOG.isDebugEnabled(); if (_isDebugEnabled) { URI _uRI = this.getURI(); String _plus = ("Loading " + _uRI); String _plus_1 = (_plus + " from storage."); StorageAwareResource.LOG.debug(_plus_1); } try { final ResourceStorageLoadable in = this.resourceStorageFacade.getOrCreateResourceStorageLoadable(this); this.loadFromStorage(in); return; } catch (final Throwable _t) { if (_t instanceof IOException) { this.contents.clear(); this.eAdapters.clear(); this.unload(); } else { throw Exceptions.sneakyThrow(_t); } } } super.load(options); }
@Test public void testFormatterIntegrationWithSerializer() { try { final Resource resource = this.factory.createResource(URI.createURI("dummy.ext")); new ResourceSetImpl().getResources().add(resource); final IDList model = FormattertestlanguageFactory.eINSTANCE.createIDList(); EList<String> _ids = model.getIds(); _ids.add("foo"); EList<EObject> _contents = resource.getContents(); _contents.add(model); final ByteArrayOutputStream out = new ByteArrayOutputStream(); BufferedOutputStream _bufferedOutputStream = new BufferedOutputStream(out); resource.save(_bufferedOutputStream, Collections.<Object, Object>emptyMap()); Assert.assertEquals("idlist foo", out.toString()); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void testXVariableDeclarationCall() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("{"); _builder.newLine(); _builder.append("\t"); _builder.append("val foo = 1"); _builder.newLine(); _builder.append("\t"); _builder.append("val bar = foo"); _builder.newLine(); _builder.append("}"); _builder.newLine(); XExpression _expression = this.expression(_builder); final XBlockExpression blockExpression = ((XBlockExpression) _expression); XExpression _get = blockExpression.getExpressions().get(1); final XVariableDeclaration variableDeclaration = ((XVariableDeclaration) _get); this.evaluatesTo(variableDeclaration, Integer.valueOf(1)); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void regionForRuleCallToEObjectParserRule() { StringConcatenation _builder = new StringConcatenation(); _builder.append("6 (child (foo))"); final Mixed mixed = this.<Mixed>parseAs(_builder, Mixed.class); final ISemanticRegionsFinder finder = this.toAccess(mixed).regionForEObject(mixed).getRegionFor(); try { finder.ruleCallTo(this._regionAccessTestLanguageGrammarAccess.getMixedRule()); Assert.fail(); } catch (final Throwable _t) { if (_t instanceof IllegalStateException) { } else { throw Exceptions.sneakyThrow(_t); } } try { finder.ruleCallsTo(this._regionAccessTestLanguageGrammarAccess.getMixedRule()); Assert.fail(); } catch (final Throwable _t_1) { if (_t_1 instanceof IllegalStateException) { } else { throw Exceptions.sneakyThrow(_t_1); } } }
@Test public void testUnreachableCase() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("switch x : new Exception {"); _builder.newLine(); _builder.append("\t"); _builder.append("Exception: 1"); _builder.newLine(); _builder.append("\t"); _builder.append("java.io.IOException: 2"); _builder.newLine(); _builder.append("\t"); _builder.append("java.io.FileNotFoundException: 3"); _builder.newLine(); _builder.append("}"); _builder.newLine(); this._validationTestHelper.assertError(this.expression(_builder), TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE, IssueCodes.UNREACHABLE_CASE); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void testSwitchNoParameter() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("{"); _builder.newLine(); _builder.append("\t"); _builder.append("switch \"lalala\" {"); _builder.newLine(); _builder.append("\t"); _builder.append("}"); _builder.newLine(); _builder.append("}"); _builder.newLine(); final XExpression block = this.expression(_builder); this._validationTestHelper.assertNoIssues(block); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void testBug415770_10() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("{"); _builder.newLine(); _builder.append("\t"); _builder.append("val Cloneable c = null"); _builder.newLine(); _builder.append("\t"); _builder.append("val String[] array = null"); _builder.newLine(); _builder.append("\t"); _builder.append("array !== c || array === c || c === array || c !== array"); _builder.newLine(); _builder.append("}"); _builder.newLine(); this._validationTestHelper.assertNoErrors(this.expression(_builder)); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void testBug415770_05() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("{"); _builder.newLine(); _builder.append("\t"); _builder.append("val String str = \"\""); _builder.newLine(); _builder.append("\t"); _builder.append("str === \"SomeString\""); _builder.newLine(); _builder.append("}"); _builder.newLine(); this._validationTestHelper.assertNoErrors(this.expression(_builder)); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void testReassignedType_02() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("{ var it = new Object() if (it instanceof String) { it = new Object() } }"); XExpression _expression = this.expression(_builder, false); XExpression _last = IterableExtensions.<XExpression>last(((XBlockExpression) _expression).getExpressions()); final XIfExpression ifExpr = ((XIfExpression) _last); XExpression _then = ifExpr.getThen(); final XBlockExpression block = ((XBlockExpression) _then); final IExpressionScope expressionScope = this._iBatchTypeResolver.resolveTypes(block).getExpressionScope(block, IExpressionScope.Anchor.BEFORE); this.contains(expressionScope, "charAt"); this.contains(expressionScope, "it"); this.contains(expressionScope, "operator_lessThan"); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void testBrokenInput_02() { try { final ContentAssistFragmentTestLanguageRoot result = this.parseHelper.parse("}} abc"); Resource _eResource = result.eResource(); final XtextResource res = ((XtextResource) _eResource); final InvariantChecker invariantChecker = new InvariantChecker(); invariantChecker.checkInvariant(res.getParseResult().getRootNode()); res.update(0, 0, "newArrayList()"); invariantChecker.checkInvariant(res.getParseResult().getRootNode()); final EObject first = IterableExtensions.<EObject>head(res.getContents()); Assert.assertTrue(first.eClass().getName(), (first instanceof ContentAssistFragmentTestLanguageRoot)); res.update("newArrayList(".length(), 0, "1"); invariantChecker.checkInvariant(res.getParseResult().getRootNode()); final EObject second = IterableExtensions.<EObject>head(res.getContents()); Assert.assertTrue(second.eClass().getName(), (second instanceof ContentAssistFragmentTestLanguageRoot)); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void testWhileLoopWithConstantCondition_01() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("while (newArrayList(\'\').empty || 2 == (1 << 1)) {"); _builder.newLine(); _builder.append("\t"); _builder.append("return \'\'"); _builder.newLine(); _builder.append("}"); _builder.newLine(); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("while ((org.eclipse.xtext.xbase.lib.CollectionLiterals.<String>newArrayList(\"\").isEmpty() || (2 == (1 << 1)))) {"); _builder_1.newLine(); _builder_1.append(" "); _builder_1.append("return \"\";"); _builder_1.newLine(); _builder_1.append("}"); _builder_1.newLine(); _builder_1.append("return null;"); _builder_1.newLine(); this.compilesTo(_builder, _builder_1); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
protected void cleanupLexerTokensFile(final AntlrGrammar lexerGrammar, final KeywordHelper helper, final IXtextGeneratorFileSystemAccess fsa) { try { boolean _isBacktrackLexer = this.options.isBacktrackLexer(); if (_isBacktrackLexer) { final MutableTokenDefProvider provider = this.createLexerTokensProvider(lexerGrammar, helper, fsa); final Iterator<Map.Entry<Integer, String>> entries = provider.getTokenDefMap().entrySet().iterator(); while (entries.hasNext()) { { final String value = entries.next().getValue(); if ((((!helper.isKeywordRule(value)) && (!value.startsWith("RULE_"))) && (!value.startsWith("SUPER_")))) { entries.remove(); } } } final CharArrayWriter writer = new CharArrayWriter(); PrintWriter _printWriter = new PrintWriter(writer); provider.writeTokenFile(_printWriter); String _tokensFileName = lexerGrammar.getTokensFileName(); char[] _charArray = writer.toCharArray(); String _string = new String(_charArray); fsa.generateFile(_tokensFileName, _string); } } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void test406762_NestedReturn() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("{"); _builder.newLine(); _builder.append("\t"); _builder.append("return return 0"); _builder.newLine(); _builder.append("}"); _builder.newLine(); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("return 0;"); _builder_1.newLine(); _builder_1.append("return /* error - couldn\'t compile nested return */;"); _builder_1.newLine(); this.compilesTo(_builder, _builder_1, false); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void testRedundantCases_01() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("switch i : 1 {"); _builder.newLine(); _builder.append("\t"); _builder.append("case 1,"); _builder.newLine(); _builder.append("}"); _builder.newLine(); this._validationTestHelper.assertError(this.expression(_builder), XbasePackage.Literals.XCASE_PART, IssueCodes.REDUNDANT_CASE); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Override public LightweightTypeReference resolvesTo(final String expression, final String type) { try { final String replacedExpressionText = expression.replace("$$", "org::eclipse::xtext::xbase::lib::"); final XExpression xExpression = this.expression(replacedExpressionText, false); Assert.assertTrue(xExpression.eResource().getErrors().toString(), xExpression.eResource().getErrors().isEmpty()); Assert.assertTrue(xExpression.eResource().getWarnings().toString(), xExpression.eResource().getWarnings().isEmpty()); final IResolvedTypes resolvedTypes = this.getTypeResolver().resolveTypes(xExpression); final LightweightTypeReference resolvedType = resolvedTypes.getReturnType(xExpression); Assert.assertEquals(replacedExpressionText, type, resolvedType.getSimpleName()); Assert.assertTrue(this.getLinkingAndSyntaxErrors(xExpression.eResource()).toString(), IterableExtensions.isEmpty(this.getLinkingAndSyntaxErrors(xExpression.eResource()))); Assert.assertTrue(xExpression.eResource().getWarnings().toString(), xExpression.eResource().getWarnings().isEmpty()); return resolvedType; } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void test1() { try { this.with(ReferenceGrammarTestLanguageStandaloneSetup.class); final String model = "kind (Hugo 13)"; final ParserRule kindRule = this.<ReferenceGrammarTestLanguageGrammarAccess>get(ReferenceGrammarTestLanguageGrammarAccess.class).getKindRule(); final XtextResource resource = this.createResource(); resource.setEntryPoint(kindRule); StringInputStream _stringInputStream = new StringInputStream(model); resource.load(_stringInputStream, CollectionLiterals.<Object, Object>emptyMap()); Assert.assertTrue(resource.getErrors().isEmpty()); Assert.assertEquals(kindRule, NodeModelUtils.getEntryParserRule(resource.getParseResult().getRootNode())); final String originalNodeModel = NodeModelUtils.compactDump(resource.getParseResult().getRootNode(), false); resource.update(0, model.length(), ((" " + model) + " ")); final String reparsedNodeModel = NodeModelUtils.compactDump(resource.getParseResult().getRootNode(), false); Assert.assertEquals(originalNodeModel, reparsedNodeModel); final ParserRule erwachsenerRule = this.<ReferenceGrammarTestLanguageGrammarAccess>get(ReferenceGrammarTestLanguageGrammarAccess.class).getErwachsenerRule(); resource.setEntryPoint(erwachsenerRule); resource.update(0, model.length(), "erwachsener (Peter 30)"); Assert.assertEquals(erwachsenerRule, NodeModelUtils.getEntryParserRule(resource.getParseResult().getRootNode())); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void testInvokeWithOverloadedMethods() { try { final StringBuilder x = new StringBuilder(); try { this.ext.invoke(x, "append", "foo"); Assert.fail(); } catch (final Throwable _t) { if (_t instanceof IllegalStateException) { } else { throw Exceptions.sneakyThrow(_t); } } } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void test406762_ValidReturnInLambdaContainedInThrow() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("throw {"); _builder.newLine(); _builder.append("\t"); _builder.append("val foo = [|return \"foo\"]"); _builder.newLine(); _builder.append("\t"); _builder.append("new Exception(foo.apply)"); _builder.newLine(); _builder.append("}"); _builder.newLine(); this._validationTestHelper.assertNoErrors(this.expression(_builder)); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void testBug377925No_Nullpointer() { try { final XExpression expression = this.expression("[Object o| null]"); final Procedure1<JvmGenericType> _function = (JvmGenericType it) -> { EList<JvmMember> _members = it.getMembers(); final Procedure1<JvmOperation> _function_1 = (JvmOperation it_1) -> { this.builder.setBody(it_1, expression); }; JvmOperation _method = this.builder.toMethod(expression, "doStuff", this.references.getTypeForName("java.lang.Object", expression), _function_1); this.builder.<JvmOperation>operator_add(_members, _method); }; final JvmGenericType clazz = this.builder.toClass(expression, "my.test.Foo", _function); this.compile(expression.eResource(), clazz); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
/** * This method delegates to 'compare(..., ...)' and expects a {@link ComparisonError} reporting a mismatch * in the given line numbers. If so the error is dropped. If the error reports different line numbers * the error is re-thrown indicating a failure in the test. If no error occurs in 'compare(..., ...)' * this test is supposed to fail. */ public void compareAndExpectMismatchInLines(final String testee, final String expected, final int lineNoTestee, final int lineNoExpected) { try { this.compare(testee, expected); } catch (final Throwable _t) { if (_t instanceof AntlrGrammarComparatorTestHelper.ComparisonError) { final AntlrGrammarComparatorTestHelper.ComparisonError e = (AntlrGrammarComparatorTestHelper.ComparisonError)_t; if (((lineNoTestee == e.lineNoTestee) && (lineNoExpected == e.lineNoExpected))) { return; } else { throw e; } } else { throw Exceptions.sneakyThrow(_t); } } StringConcatenation _builder = new StringConcatenation(); _builder.append("Expected mismatch in lines "); _builder.append(lineNoTestee); _builder.append("/"); _builder.append(lineNoExpected); _builder.append("."); AntlrGrammarComparatorTestHelper.fail(_builder.toString()); }
@Test public void testIntegerAnnotation() { try { final XAnnotationsFactory f = XAnnotationsFactory.eINSTANCE; final XExpression e = this.expression("\'Foo\'"); final XAnnotation anno = f.createXAnnotation(); JvmType _findDeclaredType = this.references.findDeclaredType(TestAnnotation3.class, e); final JvmAnnotationType annotatiomType = ((JvmAnnotationType) _findDeclaredType); anno.setAnnotationType(annotatiomType); final XAnnotationElementValuePair pair = f.createXAnnotationElementValuePair(); pair.setElement(IterableExtensions.<JvmOperation>head(annotatiomType.getDeclaredOperations())); pair.setValue(this.expression("10")); EList<XAnnotationElementValuePair> _elementValuePairs = anno.getElementValuePairs(); this._jvmTypesBuilder.<XAnnotationElementValuePair>operator_add(_elementValuePairs, pair); final JvmGenericType type = this.typesFactory.createJvmGenericType(); this._jvmTypesBuilder.addAnnotation(type, anno); Assert.assertEquals(anno.getAnnotationType(), IterableExtensions.<JvmAnnotationReference>head(type.getAnnotations()).getAnnotation()); Assert.assertEquals(1, IterableExtensions.<JvmAnnotationReference>head(type.getAnnotations()).getValues().size()); JvmAnnotationValue _head = IterableExtensions.<JvmAnnotationValue>head(IterableExtensions.<JvmAnnotationReference>head(type.getAnnotations()).getValues()); final JvmCustomAnnotationValue value = ((JvmCustomAnnotationValue) _head); EObject _head_1 = IterableExtensions.<EObject>head(value.getValues()); Assert.assertTrue((_head_1 instanceof XNumberLiteral)); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void testSugaredPropertyAccess02() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("{"); _builder.newLine(); _builder.append("\t\t\t"); _builder.append("val it = \"foo\""); _builder.newLine(); _builder.append("\t\t\t"); _builder.append("bytes"); _builder.newLine(); _builder.append("\t\t"); _builder.append("}"); this.helper.assertNoIssues(this.expression(_builder)); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void testMethodCallWithBuilderSyntax01() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("{"); _builder.newLine(); _builder.append("\t\t\t"); _builder.append("val x = #[\"foo\", \"bar\"]"); _builder.newLine(); _builder.append("\t\t\t"); _builder.append("x.forEach[]"); _builder.newLine(); _builder.append("\t\t"); _builder.append("}"); this.helper.assertNoIssues(this.expression(_builder)); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void testBug415770_07() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("{"); _builder.newLine(); _builder.append("\t"); _builder.append("val String[] array = null"); _builder.newLine(); _builder.append("\t"); _builder.append("val String[] array2 = null"); _builder.newLine(); _builder.append("\t"); _builder.append("array === array2"); _builder.newLine(); _builder.append("}"); _builder.newLine(); this._validationTestHelper.assertNoErrors(this.expression(_builder)); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Override public void generateFile(final String fileName, final String outputCfgName, final CharSequence contents) { try { final URI uri = this.getURI(fileName, outputCfgName); if (((!this.getOutputConfig(outputCfgName).isOverrideExistingResources()) && this.converter.exists(uri, CollectionLiterals.<Object, Object>emptyMap()))) { return; } final String encoding = this.getEncoding(uri); final CharSequence postProcessed = this.postProcess(fileName, outputCfgName, contents, encoding); this.generateTrace(fileName, outputCfgName, postProcessed); byte[] _bytes = postProcessed.toString().getBytes(encoding); final ByteArrayInputStream inStream = new ByteArrayInputStream(_bytes); this.generateFile(fileName, outputCfgName, inStream); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void testDuplicateCases_enum_4() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("{"); _builder.newLine(); _builder.append("\t"); _builder.append("switch x : Thread.State.NEW {"); _builder.newLine(); _builder.append("\t\t"); _builder.append("case NEW: 1"); _builder.newLine(); _builder.append("\t\t"); _builder.append("case RUNNABLE: 2"); _builder.newLine(); _builder.append("\t"); _builder.append("}"); _builder.newLine(); _builder.append("}"); _builder.newLine(); this._validationTestHelper.assertNoErrors(this.expression(_builder)); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void testMultiValueLowerBoundBacktracking() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("#17 foo"); _builder.newLine(); final Model model = this._parseHelper.parse(_builder); EObject _x11 = model.getX11(); final MultiKeywordsOrID mt = ((MultiKeywordsOrID) _x11); mt.getVal().clear(); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("Could not serialize MultiKeywordsOrID:"); _builder_1.newLine(); _builder_1.append("MultiKeywordsOrID.val violates the lower bound: It holds 0 values, but at least 1 are required."); _builder_1.newLine(); _builder_1.append("Semantic Object: Model.x11->MultiKeywordsOrID"); _builder_1.newLine(); _builder_1.append("URI: __synthetic0.sequencertestlanguage"); _builder_1.newLine(); _builder_1.append("Context: MultiKeywordsOrID returns MultiKeywordsOrID"); _builder_1.newLine(); this.assertSerializationError(model, _builder_1.toString()); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void testSwitchDeclaredParameter_5() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("{"); _builder.newLine(); _builder.append("\t"); _builder.append("switch (Integer x : \"lalala\") {"); _builder.newLine(); _builder.append("\t"); _builder.append("}"); _builder.newLine(); _builder.append("}"); _builder.newLine(); final XExpression block = this.expression(_builder); this._validationTestHelper.assertError(block, XbasePackage.Literals.XSTRING_LITERAL, IssueCodes.INCOMPATIBLE_TYPES); this._validationTestHelper.assertWarning(block, TypesPackage.Literals.JVM_FORMAL_PARAMETER, IssueCodes.UNUSED_LOCAL_VARIABLE); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void testSingleValueMandatoryGenerated() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("#1 foo bar"); _builder.newLine(); final Model model = this._parseHelper.parse(_builder); SimpleGroup _x1 = model.getX1(); _x1.setVal1(null); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("A value for feature \'val1\' is missing but required."); _builder_1.newLine(); _builder_1.append("Semantic Object: Model.x1->SimpleGroup"); _builder_1.newLine(); _builder_1.append("URI: __synthetic0.sequencertestlanguage"); _builder_1.newLine(); this.assertSerializationError(model, _builder_1.toString()); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void testSynchronizedExpression_6() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("{"); _builder.newLine(); _builder.append("\t"); _builder.append("val ()=>Object x = [|new Object]"); _builder.newLine(); _builder.append("\t"); _builder.append("synchronized (x.apply) {"); _builder.newLine(); _builder.append("\t"); _builder.append("}"); _builder.newLine(); _builder.append("}"); _builder.newLine(); this._validationTestHelper.assertNoIssues(this.expression(_builder)); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }