org.eclipse.xtext.xbase.testing.CompilationTestHelper.Result Java Examples

The following examples show how to use org.eclipse.xtext.xbase.testing.CompilationTestHelper.Result. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SkillCompilerTest.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Test
public void skillmodifier_abstract() throws Exception {
	String source = multilineString(
			"capacity C1 { }",
			"abstract skill S1 implements C1 { }"
			);
	final String expectedS1 = multilineString(
			"import io.sarl.lang.annotation.SarlElementType;",
			"import io.sarl.lang.annotation.SarlSpecification;",
			"import io.sarl.lang.annotation.SyntheticMember;",
			"import io.sarl.lang.core.Agent;",
			"import io.sarl.lang.core.Skill;",
			"",
			"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
			"@SarlElementType(" + SarlPackage.SARL_SKILL + ")",
			"@SuppressWarnings(\"all\")",
			"public abstract class S1 extends Skill implements C1 {",
			"  @SyntheticMember",
			"  public S1() {",
			"    super();",
			"  }",
			"  ",
			"  @SyntheticMember",
			"  public S1(final Agent arg0) {",
			"    super(arg0);",
			"  }",
			"}",
			""
			);
	getCompileHelper().compile(source, new IAcceptor<CompilationTestHelper.Result>() {
		@Override
		public void accept(Result r) {
			assertEquals(expectedS1,r.getGeneratedCode("S1"));
		}
	});
}
 
Example #2
Source File: SkillCompilerTest.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Test
public void actionmodifier_abstract_implicit() throws Exception {
	String source = multilineString(
			"capacity C1 { }",
			"skill S1 implements C1 {",
			"  def name",
			"}"
			);
	final String expectedS1 = multilineString(
			"import io.sarl.lang.annotation.SarlElementType;",
			"import io.sarl.lang.annotation.SarlSpecification;",
			"import io.sarl.lang.annotation.SyntheticMember;",
			"import io.sarl.lang.core.Agent;",
			"import io.sarl.lang.core.Skill;",
			"",
			"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
			"@SarlElementType(" + SarlPackage.SARL_SKILL + ")",
			"@SuppressWarnings(\"all\")",
			"public abstract class S1 extends Skill implements C1 {",
			"  public abstract void name();",
			"  ",
			"  @SyntheticMember",
			"  public S1() {",
			"    super();",
			"  }",
			"  ",
			"  @SyntheticMember",
			"  public S1(final Agent arg0) {",
			"    super(arg0);",
			"  }",
			"}",
			""
			);
	getCompileHelper().compile(source, new IAcceptor<CompilationTestHelper.Result>() {
		@Override
		public void accept(Result r) {
			assertEquals(expectedS1,r.getGeneratedCode("S1"));
		}
	});
}
 
Example #3
Source File: SkillCompilerTest.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Test
public void fieldmodifier_static() throws Exception {
	String source = multilineString(
			"capacity C1 { }",
			"skill S1 implements C1 {",
			"  static var field : int",
			"}"
			);
	final String expectedS1 = multilineString(
			"import io.sarl.lang.annotation.SarlElementType;",
			"import io.sarl.lang.annotation.SarlSpecification;",
			"import io.sarl.lang.annotation.SyntheticMember;",
			"import io.sarl.lang.core.Agent;",
			"import io.sarl.lang.core.Skill;",
			"",
			"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
			"@SarlElementType(" + SarlPackage.SARL_SKILL + ")",
			"@SuppressWarnings(\"all\")",
			"public class S1 extends Skill implements C1 {",
			"  private static int field;",
			"  ",
			"  @SyntheticMember",
			"  public S1() {",
			"    super();",
			"  }",
			"  ",
			"  @SyntheticMember",
			"  public S1(final Agent arg0) {",
			"    super(arg0);",
			"  }",
			"}",
			""
			);
	getCompileHelper().compile(source, new IAcceptor<CompilationTestHelper.Result>() {
		@Override
		public void accept(Result r) {
			assertEquals(expectedS1,r.getGeneratedCode("S1"));
		}
	});
}
 
Example #4
Source File: SkillCompilerTest.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Test
public void skillmodifier_none() throws Exception {
	String source = multilineString(
			"capacity C1 { }",
			"skill S1 implements C1 { }"
			);
	final String expectedS1 = multilineString(
			"import io.sarl.lang.annotation.SarlElementType;",
			"import io.sarl.lang.annotation.SarlSpecification;",
			"import io.sarl.lang.annotation.SyntheticMember;",
			"import io.sarl.lang.core.Agent;",
			"import io.sarl.lang.core.Skill;",
			"",
			"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
			"@SarlElementType(" + SarlPackage.SARL_SKILL + ")",
			"@SuppressWarnings(\"all\")",
			"public class S1 extends Skill implements C1 {",
			"  @SyntheticMember",
			"  public S1() {",
			"    super();",
			"  }",
			"  ",
			"  @SyntheticMember",
			"  public S1(final Agent arg0) {",
			"    super(arg0);",
			"  }",
			"}",
			""
			);
	getCompileHelper().compile(source, new IAcceptor<CompilationTestHelper.Result>() {
		@Override
		public void accept(Result r) {
			assertEquals(expectedS1,r.getGeneratedCode("S1"));
		}
	});
}
 
Example #5
Source File: SkillCompilerTest.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Test
public void skillmodifier_public() throws Exception {
	String source = multilineString(
			"capacity C1 { }",
			"public skill S1 implements C1 { }"
			);
	final String expectedS1 = multilineString(
			"import io.sarl.lang.annotation.SarlElementType;",
			"import io.sarl.lang.annotation.SarlSpecification;",
			"import io.sarl.lang.annotation.SyntheticMember;",
			"import io.sarl.lang.core.Agent;",
			"import io.sarl.lang.core.Skill;",
			"",
			"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
			"@SarlElementType(" + SarlPackage.SARL_SKILL + ")",
			"@SuppressWarnings(\"all\")",
			"public class S1 extends Skill implements C1 {",
			"  @SyntheticMember",
			"  public S1() {",
			"    super();",
			"  }",
			"  ",
			"  @SyntheticMember",
			"  public S1(final Agent arg0) {",
			"    super(arg0);",
			"  }",
			"}",
			""
			);
	getCompileHelper().compile(source, new IAcceptor<CompilationTestHelper.Result>() {
		@Override
		public void accept(Result r) {
			assertEquals(expectedS1,r.getGeneratedCode("S1"));
		}
	});
}
 
Example #6
Source File: SkillCompilerTest.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Test
public void skillmodifier_package() throws Exception {
	String source = multilineString(
			"capacity C1 { }",
			"package skill S1 implements C1 { }"
			);
	final String expectedS1 = multilineString(
			"import io.sarl.lang.annotation.SarlElementType;",
			"import io.sarl.lang.annotation.SarlSpecification;",
			"import io.sarl.lang.annotation.SyntheticMember;",
			"import io.sarl.lang.core.Agent;",
			"import io.sarl.lang.core.Skill;",
			"",
			"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
			"@SarlElementType(" + SarlPackage.SARL_SKILL + ")",
			"@SuppressWarnings(\"all\")",
			"class S1 extends Skill implements C1 {",
			"  @SyntheticMember",
			"  public S1() {",
			"    super();",
			"  }",
			"  ",
			"  @SyntheticMember",
			"  public S1(final Agent arg0) {",
			"    super(arg0);",
			"  }",
			"}",
			""
			);
	getCompileHelper().compile(source, new IAcceptor<CompilationTestHelper.Result>() {
		@Override
		public void accept(Result r) {
			assertEquals(expectedS1,r.getGeneratedCode("S1"));
		}
	});
}
 
Example #7
Source File: SkillCompilerTest.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Test
public void skillmodifier_abstract_member() throws Exception {
	String source = multilineString(
			"capacity C1 { }",
			"skill S1 implements C1 {",
			"  def name()",
			"}"
			);
	final String expectedS1 = multilineString(
			"import io.sarl.lang.annotation.SarlElementType;",
			"import io.sarl.lang.annotation.SarlSpecification;",
			"import io.sarl.lang.annotation.SyntheticMember;",
			"import io.sarl.lang.core.Agent;",
			"import io.sarl.lang.core.Skill;",
			"",
			"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
			"@SarlElementType(" + SarlPackage.SARL_SKILL + ")",
			"@SuppressWarnings(\"all\")",
			"public abstract class S1 extends Skill implements C1 {",
			"  public abstract void name();",
			"  ",
			"  @SyntheticMember",
			"  public S1() {",
			"    super();",
			"  }",
			"  ",
			"  @SyntheticMember",
			"  public S1(final Agent arg0) {",
			"    super(arg0);",
			"  }",
			"}",
			""
			);
	getCompileHelper().compile(source, new IAcceptor<CompilationTestHelper.Result>() {
		@Override
		public void accept(Result r) {
			assertEquals(expectedS1,r.getGeneratedCode("S1"));
		}
	});
}
 
Example #8
Source File: SkillCompilerTest.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Test
public void skillmodifier_final() throws Exception {
	String source = multilineString(
			"capacity C1 { }",
			"final skill S1 implements C1 { }"
			);
	final String expectedS1 = multilineString(
			"import io.sarl.lang.annotation.SarlElementType;",
			"import io.sarl.lang.annotation.SarlSpecification;",
			"import io.sarl.lang.annotation.SyntheticMember;",
			"import io.sarl.lang.core.Agent;",
			"import io.sarl.lang.core.Skill;",
			"",
			"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
			"@SarlElementType(" + SarlPackage.SARL_SKILL + ")",
			"@SuppressWarnings(\"all\")",
			"public final class S1 extends Skill implements C1 {",
			"  @SyntheticMember",
			"  public S1() {",
			"    super();",
			"  }",
			"  ",
			"  @SyntheticMember",
			"  public S1(final Agent arg0) {",
			"    super(arg0);",
			"  }",
			"}",
			""
			);
	getCompileHelper().compile(source, new IAcceptor<CompilationTestHelper.Result>() {
		@Override
		public void accept(Result r) {
			assertEquals(expectedS1,r.getGeneratedCode("S1"));
		}
	});
}
 
Example #9
Source File: VarArgsCompilerTest.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Test
public void inSkillConstructor() throws Exception {
	String source = multilineString(
			"capacity C1 {}",
			"skill S1 implements C1 {",
			"  new(arg1 : char, arg2 : boolean, arg3 : int*) {",
			"    System.out.println(arg3)",
			"  }",
			"}"
			);
	final String expected = multilineString(
			"import io.sarl.lang.annotation.SarlElementType;",
			"import io.sarl.lang.annotation.SarlSpecification;",
			"import io.sarl.lang.core.Skill;",
			"",
			"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
			"@SarlElementType(" + SarlPackage.SARL_SKILL + ")",
			"@SuppressWarnings(\"all\")",
			"public class S1 extends Skill implements C1 {",
			"  public S1(final char arg1, final boolean arg2, final int... arg3) {",
			"    System.out.println(arg3);",
			"  }",
			"}",
			""
			);
	getCompileHelper().compile(source, new IAcceptor<CompilationTestHelper.Result>() {
		@Override
		public void accept(Result r) {
			assertEquals(expected,r.getGeneratedCode("S1"));
		}
	});
}
 
Example #10
Source File: VarArgsCompilerTest.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Test
public void inSkillConstructor_singleParam() throws Exception {
	String source = multilineString(
			"capacity C1 {}",
			"skill S1 implements C1 {",
			"  new(arg : int*) {",
			"    System.out.println(arg)",
			"  }",
			"}"
			);
	final String expectedS1 = multilineString(
			"import io.sarl.lang.annotation.SarlElementType;",
			"import io.sarl.lang.annotation.SarlSpecification;",
			"import io.sarl.lang.core.Skill;",
			"",
			"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
			"@SarlElementType(" + SarlPackage.SARL_SKILL + ")",
			"@SuppressWarnings(\"all\")",
			"public class S1 extends Skill implements C1 {",
			"  public S1(final int... arg) {",
			"    System.out.println(arg);",
			"  }",
			"}",
			""
			);
	getCompileHelper().compile(source, new IAcceptor<Result>() {
		@Override
		public void accept(Result r) {
			assertEquals(expectedS1,r.getGeneratedCode("S1"));
		}
	});
}
 
Example #11
Source File: InlineFunctionTest.java    From sarl with Apache License 2.0 5 votes vote down vote up
private void compileWithInline(CharSequence source, IAcceptor<Result> acceptor) throws IOException {
	String fileName = "MyFile." + extensionProvider.getPrimaryFileExtension();
	CompilationTestHelper compiler = getCompileHelper();
	ResourceSet set = compiler.resourceSet(new Pair<String, CharSequence>(fileName, source));
	if (this.config == null) {
		this.config = this.generatorConfigProvider2.get(null);
		((GeneratorConfigProvider2) this.generatorConfigProvider2).install(set, config);
	}
	this.config.setGenerateInlineAnnotation(true);
	compiler.compile(set, acceptor);
}
 
Example #12
Source File: AnnotationsCompilerTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
protected Class<?> compileToClass(final String text) throws Exception {
	final Class<?>[] result = new Class[1];
	javaCompiler.compile(text, new IAcceptor<CompilationTestHelper.Result>() {
		
		@Override
		public void accept(Result t) {
			result[0] = t.getCompiledClass();
		}
	});
	return result[0];
}
 
Example #13
Source File: AbstractExtraLanguageGeneratorTest.java    From sarl with Apache License 2.0 5 votes vote down vote up
protected GeneratorTest compile(String source) throws IOException {
	final Result[] result = new Result[1];
	getCompileHelper().compile(source, (it) -> {
		result[0] = it;
	});
	return new GeneratorTest(result[0]);
}
 
Example #14
Source File: SkillCompilerTest.java    From sarl with Apache License 2.0 4 votes vote down vote up
@Test
public void inheritance_00() throws Exception {
	final String expectedC1 = multilineString(
			"import io.sarl.lang.annotation.SarlElementType;",
			"import io.sarl.lang.annotation.SarlSpecification;",
			"import io.sarl.lang.core.AgentTrait;",
			"import io.sarl.lang.core.Capacity;",
			"",
			"@FunctionalInterface",
			"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
			"@SarlElementType(" + SarlPackage.SARL_CAPACITY + ")",
			"@SuppressWarnings(\"all\")",
			"public interface CapTest1 extends Capacity {",
			"  public abstract int func1();",
			"  ",
			"  /**",
			"   * @ExcludeFromApidoc",
			"   */",
			"  public static class ContextAwareCapacityWrapper<C extends CapTest1> extends Capacity.ContextAwareCapacityWrapper<C> implements CapTest1 {",
			"    public ContextAwareCapacityWrapper(final C capacity, final AgentTrait caller) {",
			"      super(capacity, caller);",
			"    }",
			"    ",
			"    public int func1() {",
			"      try {",
			"        ensureCallerInLocalThread();",
			"        return this.capacity.func1();",
			"      } finally {",
			"        resetCallerInLocalThread();",
			"      }",
			"    }",
			"  }",
			"}",
			""
			);
	final String expectedC2 = multilineString(
			"import CapTest1;",
			"import io.sarl.lang.annotation.SarlElementType;",
			"import io.sarl.lang.annotation.SarlSpecification;",
			"import io.sarl.lang.core.AgentTrait;",
			"",
			"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
			"@SarlElementType(" + SarlPackage.SARL_CAPACITY + ")",
			"@SuppressWarnings(\"all\")",
			"public interface CapTest2 extends CapTest1 {",
			"  public abstract void func2(final int a);",
			"  ",
			"  /**",
			"   * @ExcludeFromApidoc",
			"   */",
			"  public static class ContextAwareCapacityWrapper<C extends CapTest2> extends CapTest1.ContextAwareCapacityWrapper<C> implements CapTest2 {",
			"    public ContextAwareCapacityWrapper(final C capacity, final AgentTrait caller) {",
			"      super(capacity, caller);",
			"    }",
			"    ",
			"    public void func2(final int a) {",
			"      try {",
			"        ensureCallerInLocalThread();",
			"        this.capacity.func2(a);",
			"      } finally {",
			"        resetCallerInLocalThread();",
			"      }",
			"    }",
			"  }",
			"}",
			""
			);
	String source = multilineString(
			"capacity CapTest1 {",
			"  def func1 : int",
			"}",
			"capacity CapTest2 extends CapTest1 {",
			"  def func2(a : int)",
			"}"
			);
	getCompileHelper().compile(source, new IAcceptor<CompilationTestHelper.Result>() {
		@Override
		public void accept(Result r) {
			assertEquals(expectedC1,r.getGeneratedCode("CapTest1"));
			assertEquals(expectedC2,r.getGeneratedCode("CapTest2"));
		}
	});
}
 
Example #15
Source File: Bug381Test.java    From sarl with Apache License 2.0 4 votes vote down vote up
@Test
public void withSarlSyntaxWithJREType() throws Exception {
	final String expected = multilineString(
			"import io.sarl.lang.annotation.ImportedCapacityFeature;",
			"import io.sarl.lang.annotation.SarlElementType;",
			"import io.sarl.lang.annotation.SarlSpecification;",
			"import io.sarl.lang.annotation.SyntheticMember;",
			"import io.sarl.lang.core.Agent;",
			"import io.sarl.lang.core.AtomicSkillReference;",
			"import io.sarl.lang.core.BuiltinCapacitiesProvider;",
			"import io.sarl.lang.core.DynamicSkillProvider;",
			"import java.util.UUID;",
			"import javax.inject.Inject;",
			"import org.eclipse.xtext.xbase.lib.Extension;",
			"import org.eclipse.xtext.xbase.lib.Pure;",
			"",
			"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
			"@SarlElementType(" + SarlPackage.SARL_AGENT + ")",
			"@SuppressWarnings(\"all\")",
			"public class A1 extends Agent {",
			"  @Extension",
			"  @ImportedCapacityFeature(C1.class)",
			"  @SyntheticMember",
			"  private transient AtomicSkillReference $CAPACITY_USE$C1;",
			"  ",
			"  @SyntheticMember",
			"  @Pure",
			"  private C1 $CAPACITY_USE$C1$CALLER() {",
			"    if (this.$CAPACITY_USE$C1 == null || this.$CAPACITY_USE$C1.get() == null) {",
			"      this.$CAPACITY_USE$C1 = $getSkill(C1.class);",
			"    }",
			"    return $castSkill(C1.class, this.$CAPACITY_USE$C1);",
			"  }",
			"  ",
			"  @SyntheticMember",
			"  public A1(final UUID arg0, final UUID arg1) {",
			"    super(arg0, arg1);",
			"  }",
			"  ",
			"  @SyntheticMember",
			"  @Deprecated",
			"  @Inject",
			"  public A1(final BuiltinCapacitiesProvider arg0, final UUID arg1, final UUID arg2) {",
			"    super(arg0, arg1, arg2);",
			"  }",
			"  ", 
			"  @SyntheticMember", 
			"  @Inject", 
			"  public A1(final UUID arg0, final UUID arg1, final DynamicSkillProvider arg2) {", 
			"    super(arg0, arg1, arg2);", 
			"  }",
			"}",
			"");

	getCompileHelper().compile(snippetWithSarlSyntaxWithJREType, new IAcceptor<CompilationTestHelper.Result>() {
		@Override
		public void accept(Result r) {
			assertEquals(expected, r.getGeneratedCode("A1"));
		}
	});
}
 
Example #16
Source File: Bug381Test.java    From sarl with Apache License 2.0 4 votes vote down vote up
@Test
public void withJavaSyntaxWithoutType() throws Exception {
	final String expected = multilineString(
			"import io.sarl.lang.annotation.ImportedCapacityFeature;",
			"import io.sarl.lang.annotation.SarlElementType;",
			"import io.sarl.lang.annotation.SarlSpecification;",
			"import io.sarl.lang.annotation.SyntheticMember;",
			"import io.sarl.lang.core.Agent;",
			"import io.sarl.lang.core.AtomicSkillReference;",
			"import io.sarl.lang.core.BuiltinCapacitiesProvider;",
			"import io.sarl.lang.core.DynamicSkillProvider;",
			"import java.util.UUID;",
			"import javax.inject.Inject;",
			"import org.eclipse.xtext.xbase.lib.Extension;",
			"import org.eclipse.xtext.xbase.lib.Pure;",
			"",
			"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
			"@SarlElementType(" + SarlPackage.SARL_AGENT + ")",
			"@SuppressWarnings(\"all\")",
			"public class A1 extends Agent {",
			"  @Extension",
			"  @ImportedCapacityFeature(C1.class)",
			"  @SyntheticMember",
			"  private transient AtomicSkillReference $CAPACITY_USE$C1;",
			"  ",
			"  @SyntheticMember",
			"  @Pure",
			"  private C1 $CAPACITY_USE$C1$CALLER() {",
			"    if (this.$CAPACITY_USE$C1 == null || this.$CAPACITY_USE$C1.get() == null) {",
			"      this.$CAPACITY_USE$C1 = $getSkill(C1.class);",
			"    }",
			"    return $castSkill(C1.class, this.$CAPACITY_USE$C1);",
			"  }",
			"  ",
			"  @SyntheticMember",
			"  public A1(final UUID arg0, final UUID arg1) {",
			"    super(arg0, arg1);",
			"  }",
			"  ",
			"  @SyntheticMember",
			"  @Deprecated",
			"  @Inject",
			"  public A1(final BuiltinCapacitiesProvider arg0, final UUID arg1, final UUID arg2) {",
			"    super(arg0, arg1, arg2);",
			"  }",
			"  ", 
			"  @SyntheticMember", 
			"  @Inject", 
			"  public A1(final UUID arg0, final UUID arg1, final DynamicSkillProvider arg2) {", 
			"    super(arg0, arg1, arg2);", 
			"  }",
			"}",
			"");

	getCompileHelper().compile(snippetWithJavaSyntaxWithoutType, new IAcceptor<CompilationTestHelper.Result>() {
		@Override
		public void accept(Result r) {
			assertEquals(expected, r.getGeneratedCode("A1"));
		}
	});
}
 
Example #17
Source File: Bug381Test.java    From sarl with Apache License 2.0 4 votes vote down vote up
@Test
public void withSarlSyntaxWithoutType() throws Exception {
	final String expected = multilineString(
			"import io.sarl.lang.annotation.ImportedCapacityFeature;",
			"import io.sarl.lang.annotation.SarlElementType;",
			"import io.sarl.lang.annotation.SarlSpecification;",
			"import io.sarl.lang.annotation.SyntheticMember;",
			"import io.sarl.lang.core.Agent;",
			"import io.sarl.lang.core.AtomicSkillReference;",
			"import io.sarl.lang.core.BuiltinCapacitiesProvider;",
			"import io.sarl.lang.core.DynamicSkillProvider;",
			"import java.util.UUID;",
			"import javax.inject.Inject;",
			"import org.eclipse.xtext.xbase.lib.Extension;",
			"import org.eclipse.xtext.xbase.lib.Pure;",
			"",
			"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
			"@SarlElementType(" + SarlPackage.SARL_AGENT + ")",
			"@SuppressWarnings(\"all\")",
			"public class A1 extends Agent {",
			"  @Extension",
			"  @ImportedCapacityFeature(C1.class)",
			"  @SyntheticMember",
			"  private transient AtomicSkillReference $CAPACITY_USE$C1;",
			"  ",
			"  @SyntheticMember",
			"  @Pure",
			"  private C1 $CAPACITY_USE$C1$CALLER() {",
			"    if (this.$CAPACITY_USE$C1 == null || this.$CAPACITY_USE$C1.get() == null) {",
			"      this.$CAPACITY_USE$C1 = $getSkill(C1.class);",
			"    }",
			"    return $castSkill(C1.class, this.$CAPACITY_USE$C1);",
			"  }",
			"  ",
			"  @SyntheticMember",
			"  public A1(final UUID arg0, final UUID arg1) {",
			"    super(arg0, arg1);",
			"  }",
			"  ",
			"  @SyntheticMember",
			"  @Deprecated",
			"  @Inject",
			"  public A1(final BuiltinCapacitiesProvider arg0, final UUID arg1, final UUID arg2) {",
			"    super(arg0, arg1, arg2);",
			"  }",
			"  ", 
			"  @SyntheticMember", 
			"  @Inject", 
			"  public A1(final UUID arg0, final UUID arg1, final DynamicSkillProvider arg2) {", 
			"    super(arg0, arg1, arg2);", 
			"  }",
			"}",
			"");

	getCompileHelper().compile(snippetWithSarlSyntaxWithoutType, new IAcceptor<CompilationTestHelper.Result>() {
		@Override
		public void accept(Result r) {
			assertEquals(expected, r.getGeneratedCode("A1"));
		}
	});
}
 
Example #18
Source File: SkillCompilerTest.java    From sarl with Apache License 2.0 4 votes vote down vote up
@Test
public void compatibleReturnType_3() throws Exception {
	final String expectedC1 = multilineString(
			"import io.sarl.lang.annotation.SarlElementType;",
			"import io.sarl.lang.annotation.SarlSpecification;",
			"import io.sarl.lang.core.AgentTrait;",
			"import io.sarl.lang.core.Capacity;",
			"",
			"@FunctionalInterface",
			"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
			"@SarlElementType(" + SarlPackage.SARL_CAPACITY + ")",
			"@SuppressWarnings(\"all\")",
			"public interface C1 extends Capacity {",
			"  public abstract float myaction(final int a);",
			"  ",
			"  /**",
			"   * @ExcludeFromApidoc",
			"   */",
			"  public static class ContextAwareCapacityWrapper<C extends C1> extends Capacity.ContextAwareCapacityWrapper<C> implements C1 {",
			"    public ContextAwareCapacityWrapper(final C capacity, final AgentTrait caller) {",
			"      super(capacity, caller);",
			"    }",
			"    ",
			"    public float myaction(final int a) {",
			"      try {",
			"        ensureCallerInLocalThread();",
			"        return this.capacity.myaction(a);",
			"      } finally {",
			"        resetCallerInLocalThread();",
			"      }",
			"    }",
			"  }",
			"}",
			""
			);
	final String expectedS1 = multilineString(
			"import io.sarl.lang.annotation.SarlElementType;",
			"import io.sarl.lang.annotation.SarlSpecification;",
			"import io.sarl.lang.annotation.SyntheticMember;",
			"import io.sarl.lang.core.Agent;",
			"import io.sarl.lang.core.Skill;",
			"",
			"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
			"@SarlElementType(" + SarlPackage.SARL_SKILL + ")",
			"@SuppressWarnings(\"all\")",
			"public class S1 extends Skill implements C1 {",
			"  public float myaction(final int a) {",
			"    return 0f;",
			"  }",
			"  ",
			"  @SyntheticMember",
			"  public S1() {",
			"    super();",
			"  }",
			"  ",
			"  @SyntheticMember",
			"  public S1(final Agent arg0) {",
			"    super(arg0);",
			"  }",
			"}",
			""
			);
	String source = multilineString(
			"capacity C1 {",
			"  def myaction(a : int) : float",
			"}",
			"skill S1 implements C1 {",
			"  def myaction(a : int) : float {",
			"    return 0f",
			"  }",
			"}"
			);
	getCompileHelper().compile(source, new IAcceptor<CompilationTestHelper.Result>() {
		@Override
		public void accept(Result r) {
			assertEquals(expectedC1,r.getGeneratedCode("C1"));
			assertEquals(expectedS1,r.getGeneratedCode("S1"));
		}
	});
}
 
Example #19
Source File: SkillCompilerTest.java    From sarl with Apache License 2.0 4 votes vote down vote up
@Test
public void compatibleReturnType_2() throws Exception {
	final String expectedC1 = multilineString(
			"import io.sarl.lang.annotation.SarlElementType;",
			"import io.sarl.lang.annotation.SarlSpecification;",
			"import io.sarl.lang.core.AgentTrait;",
			"import io.sarl.lang.core.Capacity;",
			"",
			"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
			"@SarlElementType(" + SarlPackage.SARL_CAPACITY + ")",
			"@SuppressWarnings(\"all\")",
			"public interface C1 extends Capacity {",
			"  /**",
			"   * @ExcludeFromApidoc",
			"   */",
			"  public static class ContextAwareCapacityWrapper<C extends C1> extends Capacity.ContextAwareCapacityWrapper<C> implements C1 {",
			"    public ContextAwareCapacityWrapper(final C capacity, final AgentTrait caller) {",
			"      super(capacity, caller);",
			"    }",
			"  }",
			"}",
			""
			);
	final String expectedS1 = multilineString(
			"import io.sarl.lang.annotation.SarlElementType;",
			"import io.sarl.lang.annotation.SarlSpecification;",
			"import io.sarl.lang.annotation.SyntheticMember;",
			"import io.sarl.lang.core.Agent;",
			"import io.sarl.lang.core.Skill;",
			"import org.eclipse.xtext.xbase.lib.Pure;",
			"",
			"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
			"@SarlElementType(" + SarlPackage.SARL_SKILL + ")",
			"@SuppressWarnings(\"all\")",
			"public class S1 extends Skill implements C1 {",
			"  @Pure",
			"  public float myaction(final int a) {",
			"    return 0f;",
			"  }",
			"  ",
			"  @SyntheticMember",
			"  public S1() {",
			"    super();",
			"  }",
			"  ",
			"  @SyntheticMember",
			"  public S1(final Agent arg0) {",
			"    super(arg0);",
			"  }",
			"}",
			""
			);
	String source = multilineString(
			"capacity C1 { }",
			"skill S1 implements C1 {",
			"  def myaction(a : int) : float {",
			"    return 0f",
			"  }",
			"}"
			);
	getCompileHelper().compile(source, new IAcceptor<CompilationTestHelper.Result>() {
		@Override
		public void accept(Result r) {
			assertEquals(expectedC1,r.getGeneratedCode("C1"));
			assertEquals(expectedS1,r.getGeneratedCode("S1"));
		}
	});
}
 
Example #20
Source File: SkillCompilerTest.java    From sarl with Apache License 2.0 4 votes vote down vote up
@Test
public void actionmodifier_synchronized() throws Exception {
	String source = multilineString(
			"capacity C1 { }",
			"skill S1 implements C1 {",
			"  synchronized def name { }",
			"}"
			);
	final String expectedS1 = multilineString(
			"import io.sarl.lang.annotation.SarlElementType;",
			"import io.sarl.lang.annotation.SarlSpecification;",
			"import io.sarl.lang.annotation.SyntheticMember;",
			"import io.sarl.lang.core.Agent;",
			"import io.sarl.lang.core.Skill;",
			"",
			"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
			"@SarlElementType(" + SarlPackage.SARL_SKILL + ")",
			"@SuppressWarnings(\"all\")",
			"public class S1 extends Skill implements C1 {",
			"  public synchronized void name() {",
			"  }",
			"  ",
			"  @SyntheticMember",
			"  public S1() {",
			"    super();",
			"  }",
			"  ",
			"  @SyntheticMember",
			"  public S1(final Agent arg0) {",
			"    super(arg0);",
			"  }",
			"}",
			""
			);
	getCompileHelper().compile(source, new IAcceptor<CompilationTestHelper.Result>() {
		@Override
		public void accept(Result r) {
			assertEquals(expectedS1,r.getGeneratedCode("S1"));
		}
	});
}
 
Example #21
Source File: SkillCompilerTest.java    From sarl with Apache License 2.0 4 votes vote down vote up
@Test
public void actionmodifier_static() throws Exception {
	String source = multilineString(
			"capacity C1 { }",
			"skill S1 implements C1 {",
			"  static def name { }",
			"}"
			);
	final String expectedS1 = multilineString(
			"import io.sarl.lang.annotation.SarlElementType;",
			"import io.sarl.lang.annotation.SarlSpecification;",
			"import io.sarl.lang.annotation.SyntheticMember;",
			"import io.sarl.lang.core.Agent;",
			"import io.sarl.lang.core.Skill;",
			"",
			"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
			"@SarlElementType(" + SarlPackage.SARL_SKILL + ")",
			"@SuppressWarnings(\"all\")",
			"public class S1 extends Skill implements C1 {",
			"  public static void name() {",
			"  }",
			"  ",
			"  @SyntheticMember",
			"  public S1() {",
			"    super();",
			"  }",
			"  ",
			"  @SyntheticMember",
			"  public S1(final Agent arg0) {",
			"    super(arg0);",
			"  }",
			"}",
			""
			);
	getCompileHelper().compile(source, new IAcceptor<CompilationTestHelper.Result>() {
		@Override
		public void accept(Result r) {
			assertEquals(expectedS1,r.getGeneratedCode("S1"));
		}
	});
}
 
Example #22
Source File: SkillCompilerTest.java    From sarl with Apache License 2.0 4 votes vote down vote up
@Test
public void actionmodifier_final() throws Exception {
	String source = multilineString(
			"capacity C1 { }",
			"skill S1 implements C1 {",
			"  final def name { }",
			"}"
			);
	final String expectedS1 = multilineString(
			"import io.sarl.lang.annotation.SarlElementType;",
			"import io.sarl.lang.annotation.SarlSpecification;",
			"import io.sarl.lang.annotation.SyntheticMember;",
			"import io.sarl.lang.core.Agent;",
			"import io.sarl.lang.core.Skill;",
			"",
			"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
			"@SarlElementType(" + SarlPackage.SARL_SKILL + ")",
			"@SuppressWarnings(\"all\")",
			"public class S1 extends Skill implements C1 {",
			"  public final void name() {",
			"  }",
			"  ",
			"  @SyntheticMember",
			"  public S1() {",
			"    super();",
			"  }",
			"  ",
			"  @SyntheticMember",
			"  public S1(final Agent arg0) {",
			"    super(arg0);",
			"  }",
			"}",
			""
			);
	getCompileHelper().compile(source, new IAcceptor<CompilationTestHelper.Result>() {
		@Override
		public void accept(Result r) {
			assertEquals(expectedS1,r.getGeneratedCode("S1"));
		}
	});
}
 
Example #23
Source File: SkillCompilerTest.java    From sarl with Apache License 2.0 4 votes vote down vote up
@Test
public void actionmodifier_dispatch_final() throws Exception {
	String source = multilineString(
			"capacity C1 { }",
			"skill S1 implements C1 {",
			"  dispatch final def name(a : Integer) { }",
			"}"
			);
	final String expectedS1 = multilineString(
			"import io.sarl.lang.annotation.SarlElementType;",
			"import io.sarl.lang.annotation.SarlSpecification;",
			"import io.sarl.lang.annotation.SyntheticMember;",
			"import io.sarl.lang.core.Agent;",
			"import io.sarl.lang.core.Skill;",
			"",
			"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
			"@SarlElementType(" + SarlPackage.SARL_SKILL + ")",
			"@SuppressWarnings(\"all\")",
			"public class S1 extends Skill implements C1 {",
			"  public final void _name(final Integer a) {",
			"  }",
			"  ",
			"  public void name(final Integer a) {",
			"    _name(a);",
			"    return;",
			"  }",
			"  ",
			"  @SyntheticMember",
			"  public S1() {",
			"    super();",
			"  }",
			"  ",
			"  @SyntheticMember",
			"  public S1(final Agent arg0) {",
			"    super(arg0);",
			"  }",
			"}",
			""
			);
	getCompileHelper().compile(source, new IAcceptor<CompilationTestHelper.Result>() {
		@Override
		public void accept(Result r) {
			assertEquals(expectedS1,r.getGeneratedCode("S1"));
		}
	});
}
 
Example #24
Source File: SkillCompilerTest.java    From sarl with Apache License 2.0 4 votes vote down vote up
@Test
public void fieldmodifier_private() throws Exception {
	String source = multilineString(
			"capacity C1 { }",
			"skill S1 implements C1 {",
			"  private var field : int",
			"}"
			);
	final String expectedS1 = multilineString(
			"import io.sarl.lang.annotation.SarlElementType;",
			"import io.sarl.lang.annotation.SarlSpecification;",
			"import io.sarl.lang.annotation.SyntheticMember;",
			"import io.sarl.lang.core.Agent;",
			"import io.sarl.lang.core.Skill;",
			"import org.eclipse.xtext.xbase.lib.Pure;",
			"",
			"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
			"@SarlElementType(" + SarlPackage.SARL_SKILL + ")",
			"@SuppressWarnings(\"all\")",
			"public class S1 extends Skill implements C1 {",
			"  private int field;",
			"  ",
			"  @Override",
			"  @Pure",
			"  @SyntheticMember",
			"  public boolean equals(final Object obj) {",
			"    if (this == obj)",
			"      return true;",
			"    if (obj == null)",
			"      return false;",
			"    if (getClass() != obj.getClass())",
			"      return false;",
			"    S1 other = (S1) obj;",
			"    if (other.field != this.field)",
			"      return false;",
			"    return super.equals(obj);",
			"  }",
			"  ",
			"  @Override",
			"  @Pure",
			"  @SyntheticMember",
			"  public int hashCode() {",
			"    int result = super.hashCode();",
			"    final int prime = 31;",
			"    result = prime * result + Integer.hashCode(this.field);",
			"    return result;",
			"  }",
			"  ",
			"  @SyntheticMember",
			"  public S1() {",
			"    super();",
			"  }",
			"  ",
			"  @SyntheticMember",
			"  public S1(final Agent arg0) {",
			"    super(arg0);",
			"  }",
			"}",
			""
			);
	getCompileHelper().compile(source, new IAcceptor<CompilationTestHelper.Result>() {
		@Override
		public void accept(Result r) {
			assertEquals(expectedS1,r.getGeneratedCode("S1"));
		}
	});
}
 
Example #25
Source File: AbstractExtraLanguageGeneratorTest.java    From sarl with Apache License 2.0 4 votes vote down vote up
GeneratorTest(Result result) {
	this.result = result;
}
 
Example #26
Source File: VarArgsCompilerTest.java    From sarl with Apache License 2.0 4 votes vote down vote up
@Test
public void action() throws Exception {
	String source = multilineString(
			"capacity C1 {}",
			"skill S1 implements C1 {",
			"  def myaction(arg1 : char, arg2 : boolean, arg3 : int*) {",
			"    System.out.println(arg3)",
			"  }",
			"}"
			);
	final String expectedS1 = multilineString(
			"import io.sarl.lang.annotation.SarlElementType;",
			"import io.sarl.lang.annotation.SarlSpecification;",
			"import io.sarl.lang.annotation.SyntheticMember;",
			"import io.sarl.lang.core.Agent;",
			"import io.sarl.lang.core.Skill;",
			"",
			"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
			"@SarlElementType(" + SarlPackage.SARL_SKILL + ")",
			"@SuppressWarnings(\"all\")",
			"public class S1 extends Skill implements C1 {",
			"  public void myaction(final char arg1, final boolean arg2, final int... arg3) {",
			"    System.out.println(arg3);",
			"  }",
			"  ",
			"  @SyntheticMember",
			"  public S1() {",
			"    super();",
			"  }",
			"  ",
			"  @SyntheticMember",
			"  public S1(final Agent arg0) {",
			"    super(arg0);",
			"  }",
			"}",
			""
			);
	getCompileHelper().compile(source, new IAcceptor<Result>() {
		@Override
		public void accept(Result r) {
			assertEquals(expectedS1,r.getGeneratedCode("S1"));
		}
	});
}
 
Example #27
Source File: PureFunctionTest.java    From sarl with Apache License 2.0 4 votes vote down vote up
@Test
public void noPureParent_pureLocal_tooComplexToBeDetected() throws Exception {
	String source = multilineString(
			"class C1 {",
			"	def fct { return Math.random }",
			"}",
			"class C2 extends C1 {",
			"	override fct : double { 0 }",
			"}",
			"");
	final String expectedC1 = multilineString(
			"import io.sarl.lang.annotation.SarlElementType;",
			"import io.sarl.lang.annotation.SarlSpecification;",
			"import io.sarl.lang.annotation.SyntheticMember;",
			"import org.eclipse.xtext.xbase.lib.Pure;",
			"",
			"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
			"@SarlElementType(" + SarlPackage.SARL_CLASS + ")",
			"@SuppressWarnings(\"all\")",
			"public class C1 {",
			"  @Pure",
			"  public double fct() {",
			"    return Math.random();",
			"  }",
			"  ",
			"  @SyntheticMember",
			"  public C1() {",
			"    super();",
			"  }",
			"}",
			""
			);
	final String expectedC2 = multilineString(
			"import io.sarl.lang.annotation.SarlElementType;",
			"import io.sarl.lang.annotation.SarlSpecification;",
			"import io.sarl.lang.annotation.SyntheticMember;",
			"import org.eclipse.xtext.xbase.lib.Pure;",
			"",
			"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
			"@SarlElementType(" + SarlPackage.SARL_CLASS + ")",
			"@SuppressWarnings(\"all\")",
			"public class C2 extends C1 {",
			"  @Override",
			"  @Pure",
			"  public double fct() {",
			"    return 0;",
			"  }",
			"  ",
			"  @SyntheticMember",
			"  public C2() {",
			"    super();",
			"  }",
			"}",
			""
			);
	getCompileHelper().compile(source, new IAcceptor<CompilationTestHelper.Result>() {
		@Override
		public void accept(Result r) {
			assertEquals(expectedC1, r.getGeneratedCode("C1"));
			assertEquals(expectedC2, r.getGeneratedCode("C2"));
		}
	});
}
 
Example #28
Source File: PureFunctionTest.java    From sarl with Apache License 2.0 4 votes vote down vote up
@Test
public void pureParent_pureLocal_tooComplexToBeDetected() throws Exception {
	String source = multilineString(
			"class C1 {",
			"	def fct { }",
			"}",
			"class C2 extends C1 {",
			"	override fct { }",
			"}",
			"");
	final String expectedC1 = multilineString(
			"import io.sarl.lang.annotation.SarlElementType;",
			"import io.sarl.lang.annotation.SarlSpecification;",
			"import io.sarl.lang.annotation.SyntheticMember;",
			"",
			"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
			"@SarlElementType(" + SarlPackage.SARL_CLASS + ")",
			"@SuppressWarnings(\"all\")",
			"public class C1 {",
			"  public void fct() {",
			"  }",
			"  ",
			"  @SyntheticMember",
			"  public C1() {",
			"    super();",
			"  }",
			"}",
			""
			);
	final String expectedC2 = multilineString(
			"import io.sarl.lang.annotation.SarlElementType;",
			"import io.sarl.lang.annotation.SarlSpecification;",
			"import io.sarl.lang.annotation.SyntheticMember;",
			"",
			"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
			"@SarlElementType(" + SarlPackage.SARL_CLASS + ")",
			"@SuppressWarnings(\"all\")",
			"public class C2 extends C1 {",
			"  @Override",
			"  public void fct() {",
			"  }",
			"  ",
			"  @SyntheticMember",
			"  public C2() {",
			"    super();",
			"  }",
			"}",
			""
			);
	getCompileHelper().compile(source, new IAcceptor<CompilationTestHelper.Result>() {
		@Override
		public void accept(Result r) {
			assertEquals(expectedC1, r.getGeneratedCode("C1"));
			assertEquals(expectedC2, r.getGeneratedCode("C2"));
		}
	});
}
 
Example #29
Source File: PureFunctionTest.java    From sarl with Apache License 2.0 4 votes vote down vote up
@Test
public void abstractParent_pureLocal_tooComplexToBeDetected() throws Exception {
	String source = multilineString(
			"abstract class C1 {",
			"	abstract def fct : double",
			"}",
			"class C2 extends C1 {",
			"	override fct : double { 0 }",
			"}",
			"");
	final String expectedC1 = multilineString(
			"import io.sarl.lang.annotation.SarlElementType;",
			"import io.sarl.lang.annotation.SarlSpecification;",
			"import io.sarl.lang.annotation.SyntheticMember;",
			"",
			"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
			"@SarlElementType(" + SarlPackage.SARL_CLASS + ")",
			"@SuppressWarnings(\"all\")",
			"public abstract class C1 {",
			"  public abstract double fct();",
			"  ",
			"  @SyntheticMember",
			"  public C1() {",
			"    super();",
			"  }",
			"}",
			""
			);
	final String expectedC2 = multilineString(
			"import io.sarl.lang.annotation.SarlElementType;",
			"import io.sarl.lang.annotation.SarlSpecification;",
			"import io.sarl.lang.annotation.SyntheticMember;",
			"",
			"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
			"@SarlElementType(" + SarlPackage.SARL_CLASS + ")",
			"@SuppressWarnings(\"all\")",
			"public class C2 extends C1 {",
			"  @Override",
			"  public double fct() {",
			"    return 0;",
			"  }",
			"  ",
			"  @SyntheticMember",
			"  public C2() {",
			"    super();",
			"  }",
			"}",
			""
			);
	getCompileHelper().compile(source, new IAcceptor<CompilationTestHelper.Result>() {
		@Override
		public void accept(Result r) {
			assertEquals(expectedC1, r.getGeneratedCode("C1"));
			assertEquals(expectedC2, r.getGeneratedCode("C2"));
		}
	});
}
 
Example #30
Source File: ClassCompilerTest.java    From sarl with Apache License 2.0 4 votes vote down vote up
public void methodOverriding_inferredReturnType() throws Exception {
	String source = multilineString(
			"package io.sarl.docs.reference.oop",
			"class Person {",
			"	var firstName : String",
			"	var lastName : String",
			"	def getFullName : String {",
			"		this.firstName + \" \" + this.lastName",
			"	}",
			"}",
			"class PersonEx extends Person {",
			"	var title : String",
			"	override getFullName {",
			"		return title + \" \" + super.fullName",
			"	}",
			"}");
	final String expectedPerson = multilineString(
			"package io.sarl.docs.reference.oop;",
			"",
			"@SuppressWarnings(\"all\")",
			"public class Person {",
			"  private String firstName;",
			"  ",
			"  private String lastName;",
			"  ",
			"  public String getFullName() {",
			"    return ((this.firstName + \" \") + this.lastName);",
			"  }",
			"}",
			"");
	final String expectedPersonEx = multilineString(
			"package io.sarl.docs.reference.oop;",
			"",
			"import io.sarl.docs.reference.oop.Person;",
			"",
			"@SuppressWarnings(\"all\")",
			"public class PersonEx extends Person {",
			"  private String title;",
			"  ",
			"  @Override",
			"  public String getFullName() {",
			"    String _fullName = super.getFullName();",
			"    return ((this.title + \" \") + _fullName);",
			"  }",
			"}",
			""
			);
	getCompileHelper().compile(source, new IAcceptor<Result>() {
		@Override
		public void accept(Result r) {
			assertEquals(expectedPerson, r.getGeneratedCode("io.sarl.docs.reference.oop.Person"));
			assertEquals(expectedPersonEx, r.getGeneratedCode("io.sarl.docs.reference.oop.PersonEx"));
		}
	});
}