protected void doTestEnum_05(String paramName) throws Exception {
   String typeName = TestEnum.class.getName();
   JvmEnumerationType type = (JvmEnumerationType) getTypeProvider().findTypeByName(typeName);
   boolean constructorSeen = false;
   for (JvmMember member : type.getMembers()) {
     if (member instanceof JvmConstructor) {
       constructorSeen = true;
       List<JvmFormalParameter> parameters = ((JvmConstructor) member).getParameters();
       assertEquals(1, parameters.size());
       JvmFormalParameter singleParam = parameters.get(0);
       assertEquals(paramName, singleParam.getName());
     }
   }
   assertTrue("constructorSeen", constructorSeen);
 }
Exemplo n.º 2
0
 @Test
 public void testEnumArtificialMethods() {
   try {
     StringConcatenation _builder = new StringConcatenation();
     _builder.append("package bar");
     _builder.newLine();
     _builder.newLine();
     _builder.append("enum Foo {");
     _builder.newLine();
     _builder.append("}");
     _builder.newLine();
     String _string = _builder.toString();
     XtendEnum _enumeration = this.enumeration(_string);
     JvmEnumerationType _inferredEnumerationType =
         this._iXtendJvmAssociations.getInferredEnumerationType(_enumeration);
     final EList<JvmMember> inferred = _inferredEnumerationType.getMembers();
     int _size = inferred.size();
     Assert.assertEquals(2, _size);
     JvmMember _get = inferred.get(0);
     final JvmOperation values = ((JvmOperation) _get);
     String _identifier = values.getIdentifier();
     Assert.assertEquals("bar.Foo.values()", _identifier);
     boolean _isStatic = values.isStatic();
     Assert.assertTrue(_isStatic);
     JvmVisibility _visibility = values.getVisibility();
     Assert.assertEquals(JvmVisibility.PUBLIC, _visibility);
     JvmMember _get_1 = inferred.get(1);
     final JvmOperation valueOf = ((JvmOperation) _get_1);
     String _identifier_1 = valueOf.getIdentifier();
     Assert.assertEquals("bar.Foo.valueOf(java.lang.String)", _identifier_1);
     boolean _isStatic_1 = valueOf.isStatic();
     Assert.assertTrue(_isStatic_1);
     JvmVisibility _visibility_1 = valueOf.getVisibility();
     Assert.assertEquals(JvmVisibility.PUBLIC, _visibility_1);
   } catch (Throwable _e) {
     throw Exceptions.sneakyThrow(_e);
   }
 }
Exemplo n.º 3
0
 @Test
 public void testEnumLiteralIsStatic() {
   try {
     StringConcatenation _builder = new StringConcatenation();
     _builder.append("enum Foo {");
     _builder.newLine();
     _builder.append("\t");
     _builder.append("BAR");
     _builder.newLine();
     _builder.append("}");
     _builder.newLine();
     String _string = _builder.toString();
     XtendEnum _enumeration = this.enumeration(_string);
     JvmEnumerationType _inferredEnumerationType =
         this._iXtendJvmAssociations.getInferredEnumerationType(_enumeration);
     EList<JvmMember> _members = _inferredEnumerationType.getMembers();
     JvmMember _head = IterableExtensions.<JvmMember>head(_members);
     final JvmEnumerationLiteral inferred = ((JvmEnumerationLiteral) _head);
     boolean _isStatic = inferred.isStatic();
     Assert.assertTrue(_isStatic);
   } catch (Throwable _e) {
     throw Exceptions.sneakyThrow(_e);
   }
 }