Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Simplify the test API for making the compilation tests faster.
see #616

Signed-off-by: Stéphane Galland <galland@arakhne.org>
  • Loading branch information
gallandarakhneorg committed Nov 19, 2018
1 parent 9ebe793 commit e3966d5
Show file tree
Hide file tree
Showing 91 changed files with 516 additions and 37,835 deletions.
2 changes: 1 addition & 1 deletion main/targetplatform/io.sarl.lang.targetplatform.target
Expand Up @@ -49,4 +49,4 @@
</location>
</locations>
<targetJRE path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
</target>
</target>
Expand Up @@ -20,10 +20,6 @@
*/
package io.sarl.core.tests;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
Expand Down
Expand Up @@ -20,8 +20,6 @@
*/
package io.sarl.core.tests;

import static org.junit.Assert.assertSame;

import java.util.UUID;

import org.junit.Before;
Expand Down
Expand Up @@ -15,9 +15,6 @@
*/
package io.sarl.lang.core.tests.core;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;

import java.util.UUID;
Expand Down
Expand Up @@ -20,11 +20,6 @@
*/
package io.sarl.lang.core.tests.core;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;

import java.util.UUID;

import org.junit.Before;
Expand Down
Expand Up @@ -20,12 +20,6 @@
*/
package io.sarl.lang.core.tests.core;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;

import java.util.UUID;

import org.junit.Before;
Expand Down
Expand Up @@ -20,8 +20,6 @@
*/
package io.sarl.lang.core.tests.core;

import static org.junit.Assert.assertSame;

import java.util.UUID;

import org.junit.Before;
Expand Down
Expand Up @@ -34,9 +34,6 @@
@SuppressWarnings("all")
public class Bug23 extends AbstractSarlTest {

@Inject
private CompilationTestHelper compiler;

private String snippet = multilineString(
"import java.util.UUID\n",
"event AgentSpawned {",
Expand Down Expand Up @@ -131,7 +128,7 @@ public void myAgentSpawnedCompile() throws Exception {
""
);

this.compiler.compile(snippet, (r) -> assertEquals(expectedMyAgentSpawned,r.getGeneratedCode("MyAgentSpawned")));
getCompileHelper().compile(snippet, (r) -> assertEquals(expectedMyAgentSpawned,r.getGeneratedCode("MyAgentSpawned")));
}

}
Expand Up @@ -95,9 +95,6 @@ public class Bug291 extends AbstractSarlTest {
"}",
"");

@Inject
private CompilationTestHelper compiler;

@Test
public void testParser() throws Exception {
SarlScript script = file(SOURCE_01);
Expand All @@ -106,7 +103,7 @@ public void testParser() throws Exception {

@Test
public void testCompiler() throws Exception {
this.compiler.compile(SOURCE_01, (r) -> {
getCompileHelper().compile(SOURCE_01, (r) -> {
assertEquals(EXPECTED_01, r.getGeneratedCode("io.sarl.lang.tests.bug291.S1"));
});
}
Expand Down
Expand Up @@ -78,9 +78,6 @@ private static void assertActionKeys(Iterable<ActionPrototype> actual, String...
*/
public static class CompilerTests extends AbstractSarlTest {

@Inject
private CompilationTestHelper compiler;

@Test
public void testCompiler() throws Exception {
final String expectedPhysicEnvironment = multilineString(
Expand Down Expand Up @@ -312,7 +309,7 @@ public void testCompiler() throws Exception {
"}",
"");

this.compiler.compile(multilineString(capacityCode, skillCode), (r) -> {
getCompileHelper().compile(multilineString(capacityCode, skillCode), (r) -> {
assertEquals(expectedPhysicEnvironment, r.getGeneratedCode("PhysicEnvironment"));
assertEquals(expectedStandardPhysicEnvironment, r.getGeneratedCode("StandardPhysicEnvironment"));
});
Expand Down
Expand Up @@ -51,9 +51,6 @@ public static class CapacityTest extends AbstractSarlTest {
" def move(direction2 : Vector2i, changeHeading2 : boolean = false)",
"}");

@Inject
private CompilationTestHelper compiler;

@Test
public void bug312() throws Exception {
SarlScript mas = file(snippet);
Expand Down Expand Up @@ -155,7 +152,7 @@ public void testCompiler() throws Exception {
" }",
"}",
"");
this.compiler.compile(this.snippet, (r) -> assertEquals(expected, r.getGeneratedCode("C1")));
getCompileHelper().compile(this.snippet, (r) -> assertEquals(expected, r.getGeneratedCode("C1")));
}

}
Expand Down
Expand Up @@ -140,9 +140,6 @@ public void withJavaSyntaxWithoutType() throws Exception {
}

public static class CompilerTest extends AbstractSarlTest {

@Inject
private CompilationTestHelper compiler;

@Test
public void withSarlSyntaxWithLocalType() throws Exception {
Expand Down Expand Up @@ -201,7 +198,7 @@ public void withSarlSyntaxWithLocalType() throws Exception {
"}",
"");

this.compiler.compile(snippetWithSarlSyntaxWithLocalType,
getCompileHelper().compile(snippetWithSarlSyntaxWithLocalType,
(r) -> assertEquals(expected, r.getGeneratedCode("A1")));
}

Expand Down Expand Up @@ -262,7 +259,7 @@ public void withJavaSyntaxWithLocalType() throws Exception {
"}",
"");

this.compiler.compile(snippetWithJavaSyntaxWithLocalType,
getCompileHelper().compile(snippetWithJavaSyntaxWithLocalType,
(r) -> assertEquals(expected, r.getGeneratedCode("A1")));
}

Expand Down Expand Up @@ -323,7 +320,7 @@ public void withSarlSyntaxWithJREType() throws Exception {
"}",
"");

this.compiler.compile(snippetWithSarlSyntaxWithJREType, new IAcceptor<CompilationTestHelper.Result>() {
getCompileHelper().compile(snippetWithSarlSyntaxWithJREType, new IAcceptor<CompilationTestHelper.Result>() {
@Override
public void accept(Result r) {
assertEquals(expected, r.getGeneratedCode("A1"));
Expand Down Expand Up @@ -388,7 +385,7 @@ public void withJavaSyntaxWithJREType() throws Exception {
"}",
"");

this.compiler.compile(snippetWithJavaSyntaxWithJREType,
getCompileHelper().compile(snippetWithJavaSyntaxWithJREType,
(r) -> assertEquals(expected, r.getGeneratedCode("A1")));
}

Expand Down Expand Up @@ -449,7 +446,7 @@ public void withSarlSyntaxWithoutType() throws Exception {
"}",
"");

this.compiler.compile(snippetWithSarlSyntaxWithoutType, new IAcceptor<CompilationTestHelper.Result>() {
getCompileHelper().compile(snippetWithSarlSyntaxWithoutType, new IAcceptor<CompilationTestHelper.Result>() {
@Override
public void accept(Result r) {
assertEquals(expected, r.getGeneratedCode("A1"));
Expand Down Expand Up @@ -514,7 +511,7 @@ public void withJavaSyntaxWithoutType() throws Exception {
"}",
"");

this.compiler.compile(snippetWithJavaSyntaxWithoutType, new IAcceptor<CompilationTestHelper.Result>() {
getCompileHelper().compile(snippetWithJavaSyntaxWithoutType, new IAcceptor<CompilationTestHelper.Result>() {
@Override
public void accept(Result r) {
assertEquals(expected, r.getGeneratedCode("A1"));
Expand Down
Expand Up @@ -66,9 +66,6 @@ public void parsing() throws Exception {
}

public static class CompilerTest extends AbstractSarlTest {

@Inject
private CompilationTestHelper compiler;

@Test
public void compilation() throws Exception {
Expand Down Expand Up @@ -143,7 +140,7 @@ public void compilation() throws Exception {
"}",
"");

this.compiler.compile(snippet,
getCompileHelper().compile(snippet,
(r) -> assertEquals(expected, r.getGeneratedCode("A1")));
}

Expand Down
Expand Up @@ -45,9 +45,6 @@
@SuppressWarnings("all")
public class Bug92 extends AbstractSarlTest {

@Inject
private CompilationTestHelper compiler;

protected static void assertInstance(Class<?> expected, Object actual) {
if (actual != null && !expected.isInstance(actual)) {
fail("Unexpected type of object. The object must be a " + expected.getName() + " but it is: " + actual);
Expand Down Expand Up @@ -140,7 +137,7 @@ public void attributeDeclarationSyntax_double() throws Exception {

@Test
public void attributeDeclarationCompiler_inferredDouble() throws Exception {
this.compiler.assertCompilesTo(
getCompileHelper().assertCompilesTo(
multilineString(
"agent A1 {",
" var myDouble = 0d",
Expand Down Expand Up @@ -212,7 +209,7 @@ public void attributeDeclarationCompiler_inferredDouble() throws Exception {

@Test
public void attributeDeclarationCompiler_Double() throws Exception {
this.compiler.assertCompilesTo(
getCompileHelper().assertCompilesTo(
multilineString(
"agent A1 {",
" var myDouble : Double = 0d",
Expand Down Expand Up @@ -284,7 +281,7 @@ public void attributeDeclarationCompiler_Double() throws Exception {

@Test
public void attributeDeclarationCompiler_double() throws Exception {
this.compiler.assertCompilesTo(
getCompileHelper().assertCompilesTo(
multilineString(
"agent A1 {",
" var myDouble : double = 0d",
Expand Down Expand Up @@ -532,7 +529,7 @@ public void originialCode_withDoubleType() throws Exception {
"}",
"");

this.compiler.compile(source, (r) -> {
getCompileHelper().compile(source, (r) -> {
assertEquals(expected1,r.getGeneratedCode("ComputeEnergyCapacity"));
assertEquals(expected2,r.getGeneratedCode("DeviceAgent"));
assertEquals(expected3,r.getGeneratedCode("EntityAgent"));
Expand Down Expand Up @@ -717,7 +714,7 @@ public void originialCode_withoutDoubleType() throws Exception {
"}",
"");

this.compiler.compile(source, (r) -> {
getCompileHelper().compile(source, (r) -> {
assertEquals(expected1,r.getGeneratedCode("ComputeEnergyCapacity"));
assertEquals(expected2,r.getGeneratedCode("DeviceAgent"));
assertEquals(expected3,r.getGeneratedCode("EntityAgent"));
Expand Down
Expand Up @@ -83,12 +83,9 @@ public class Bug459 {

public static class Compilation extends AbstractSarlTest {

@Inject
private CompilationTestHelper compiler;

@Test
public void withoutFunction() throws Exception {
this.compiler.assertCompilesTo(SNIPSET1,
getCompileHelper().assertCompilesTo(SNIPSET1,
multilineString(
"package io.sarl.lang.bug459;",
"",
Expand All @@ -115,7 +112,7 @@ public void withoutFunction() throws Exception {

@Test
public void withFunction() throws Exception {
this.compiler.assertCompilesTo(SNIPSET2,
getCompileHelper().assertCompilesTo(SNIPSET2,
multilineString(
"package io.sarl.lang.bug459;",
"",
Expand Down Expand Up @@ -181,7 +178,7 @@ public void withFunction() throws Exception {

@Test
public void singleInheritanceWithoutFunction() throws Exception {
this.compiler.compile(SNIPSET3,
getCompileHelper().compile(SNIPSET3,
(it) -> {
assertEquals(multilineString(
"package io.sarl.lang.bug459;",
Expand Down Expand Up @@ -210,7 +207,7 @@ public void singleInheritanceWithoutFunction() throws Exception {

@Test
public void singleInheritanceWithFunction() throws Exception {
this.compiler.compile(SNIPSET4,
getCompileHelper().compile(SNIPSET4,
(it) -> {
assertEquals(multilineString(
"package io.sarl.lang.bug459;",
Expand Down Expand Up @@ -278,7 +275,7 @@ public void singleInheritanceWithFunction() throws Exception {

@Test
public void multiInheritanceWithoutFunction() throws Exception {
this.compiler.compile(SNIPSET5,
getCompileHelper().compile(SNIPSET5,
(it) -> {
assertEquals(multilineString(
"package io.sarl.lang.bug459;",
Expand Down Expand Up @@ -317,7 +314,7 @@ public void multiInheritanceWithoutFunction() throws Exception {

@Test
public void multiInheritanceWithFunction() throws Exception {
this.compiler.compile(SNIPSET6,
getCompileHelper().compile(SNIPSET6,
(it) -> {
assertEquals(multilineString(
"package io.sarl.lang.bug459;",
Expand Down Expand Up @@ -395,7 +392,7 @@ public void multiInheritanceWithFunction() throws Exception {

@Test
public void withVarArg() throws Exception {
this.compiler.assertCompilesTo(SNIPSET7,
getCompileHelper().assertCompilesTo(SNIPSET7,
multilineString(
"package io.sarl.lang.bug459;",
"",
Expand Down

0 comments on commit e3966d5

Please sign in to comment.