Commit 66f9729b authored by Johannes Mey's avatar Johannes Mey
Browse files

move multiple files test to junit/gradle

parent bb92be21
......@@ -8,4 +8,6 @@ src/gen/
src/test/jastadd/relations/Relations.ast
src/test/jastadd/relations/Relations.jadd
src/test/jastadd/lowerbounds/LowerBounds.ast
src/test/jastadd/lowerbounds/LowerBounds.jadd
\ No newline at end of file
src/test/jastadd/lowerbounds/LowerBounds.jadd
src/test/jastadd/multiple/Multiple.ast
src/test/jastadd/multiple/Multiple.jadd
\ No newline at end of file
......@@ -157,13 +157,41 @@ task compileLowerBoundsTest(type: JavaExec, group: 'verification') {
args '--o=src/test/java-gen/', '--package=lowerbounds.ast', 'src/test/jastadd/lowerbounds/LowerBounds.ast', 'src/test/jastadd/lowerbounds/LowerBounds.jadd', 'src/test/jastadd/Utils.jadd'
}
task preprocessMultipleTest(type: JavaExec, group: 'verification') {
doFirst {
delete 'src/test/jastadd/multiple/Multiple.ast', 'src/test/jastadd/multiple/Multiple.jadd'
}
classpath = sourceSets.main.runtimeClasspath
main = 'org.jastadd.relast.compiler.Compiler'
args 'src/test/jastadd/multiple/Part1.relast', 'src/test/jastadd/multiple/Part2.relast', 'src/test/jastadd/multiple/Part3.relast', '--file', '--grammarName=src/test/jastadd/multiple/Multiple'
}
task compileMultipleTest(type: JavaExec, group: 'verification') {
doFirst {
delete 'src/test/java-gen/multiple'
}
classpath = sourceSets.main.runtimeClasspath
main = 'org.jastadd.JastAdd'
args '--o=src/test/java-gen/', '--package=multiple.ast', 'src/test/jastadd/multiple/Multiple.ast', 'src/test/jastadd/multiple/Multiple.jadd', 'src/test/jastadd/Utils.jadd'
}
test {
outputs.upToDateWhen { false }
useJUnitPlatform()
}
test.dependsOn compileRelationTest
test.dependsOn compileLowerBoundsTest
doublePreprocessRelationTest.dependsOn preprocessRelationTest
compileRelationTest.dependsOn doublePreprocessRelationTest
compileLowerBoundsTest.dependsOn preprocessLowerBoundsTest
\ No newline at end of file
doublePreprocessRelationTest.dependsOn preprocessRelationTest
test.dependsOn compileLowerBoundsTest
compileLowerBoundsTest.dependsOn preprocessLowerBoundsTest
test.dependsOn compileMultipleTest
compileMultipleTest.dependsOn preprocessMultipleTest
\ No newline at end of file
package org.jastadd.relast.tests;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import relations.ast.A;
import relations.ast.B;
import relations.ast.Root;
import java.util.Arrays;
import static org.junit.jupiter.api.Assertions.*;
@SuppressWarnings("ArraysAsListWithZeroOrOneArgument")
class MultipleFiles {
private Root r;
private A a1;
private A a2;
private A a3;
private B b1;
private B b2;
private B b3;
/**
* rel A.Di1 -> B;
*/
@Test
void testDi1() {
setup();
a1.setDi1(b2);
a2.setDi1(b1);
assertSame(a1.getDi1(), b2);
assertSame(a2.getDi1(), b1);
a2.setDi1(b2);
assertSame(a1.getDi1(), b2);
assertSame(a2.getDi1(), b2);
try {
a3.setDi1(null);
fail("should throw an exception");
} catch (Exception e) {
// OK
}
}
/**
* rel A.Di2? -> B;
*/
@Test
void testDi2() {
setup();
a1.setDi2(b2);
a2.setDi2(b1);
assertSame(a1.getDi2(), b2);
assertSame(a2.getDi2(), b1);
a2.setDi2(b2);
assertSame(a1.getDi2(), b2);
assertSame(a2.getDi2(), b2);
a2.clearDi2();
assertSame(a1.getDi2(), b2);
assertNull(a2.getDi2());
assertTrue(a1.hasDi2());
assertFalse(a2.hasDi2());
assertFalse(a3.hasDi2());
}
/**
* rel A.Di3* -> B;
*/
@Test
void testDi3() {
setup();
a1.addDi3(b1);
a1.addDi3(b2);
a1.addDi3(b3);
a2.addDi3(b2);
assertEquals(a1.getDi3s(), Arrays.asList(b1, b2, b3));
assertEquals(a1.getDi3List(), Arrays.asList(b1, b2, b3));
assertEquals(a2.getDi3s(), Arrays.asList(b2));
assertEquals(a2.getDi3List(), Arrays.asList(b2));
assertEquals(a3.getDi3s(), Arrays.asList());
assertEquals(a3.getDi3List(), Arrays.asList());
a1.addDi3(b1);
a2.addDi3(b1);
a2.addDi3(b2);
assertEquals(a1.getDi3s(), Arrays.asList(b1, b2, b3, b1));
assertEquals(a1.getDi3List(), Arrays.asList(b1, b2, b3, b1));
assertEquals(a2.getDi3s(), Arrays.asList(b2, b1, b2));
assertEquals(a2.getDi3List(), Arrays.asList(b2, b1, b2));
assertEquals(a3.getDi3s(), Arrays.asList());
assertEquals(a3.getDi3List(), Arrays.asList());
a1.removeDi3(b1);
a2.removeDi3(b2);
assertEquals(a1.getDi3s(), Arrays.asList(b2, b3, b1));
assertEquals(a1.getDi3List(), Arrays.asList(b2, b3, b1));
assertEquals(a2.getDi3s(), Arrays.asList(b1, b2));
assertEquals(a2.getDi3List(), Arrays.asList(b1, b2));
assertEquals(a3.getDi3s(), Arrays.asList());
assertEquals(a3.getDi3List(), Arrays.asList());
}
/**
* rel A.Bi1 <-> B.Bi1;
*/
@Test
void testBi11() {
// Init
setup();
a1.setBi1(b1);
a2.setBi1(b2);
// Change
a2.setBi1(b1);
assertNull(a1.getBi1());
assertSame(a2.getBi1(), b1);
assertSame(b1.getBi1(), a2);
assertNull(b2.getBi1());
}
@Test
void testBi12() {
// Init
setup();
a1.setBi1(b2);
// Change
a2.setBi1(b2);
assertNull(a1.getBi1());
assertSame(a2.getBi1(), b2);
assertNull(b1.getBi1());
assertSame(b2.getBi1(), a2);
}
/**
* rel A.Bi2 <-> B.Bi2?;
*/
@Test
void testBi21() {
// Init
setup();
a1.setBi2(b1);
a2.setBi2(b2);
// Change
a2.setBi2(b1);
assertNull(a1.getBi2());
assertSame(a2.getBi2(), b1);
assertSame(b1.getBi2(), a2);
assertNull(b2.getBi2());
}
@Test
void testBi22() {
// Init
setup();
a1.setBi2(b2);
// Change
a2.setBi2(b2);
assertNull(a1.getBi2());
assertSame(a2.getBi2(), b2);
assertNull(b1.getBi2());
assertSame(b2.getBi2(), a2);
}
/**
* rel A.Bi3 <-> B.Bi3*;
*/
@Test
void testBi3() {
setup();
a2.setBi3(b2);
assertNull(a1.getBi3());
assertSame(a2.getBi3(), b2);
assertEquals(b1.getBi3s(), Arrays.asList());
assertEquals(b1.getBi3List(), Arrays.asList());
assertEquals(b2.getBi3s(), Arrays.asList(a2));
assertEquals(b2.getBi3List(), Arrays.asList(a2));
assertEquals(b3.getBi3s(), Arrays.asList());
assertEquals(b3.getBi3List(), Arrays.asList());
a2.setBi3(b3);
assertNull(a1.getBi3());
assertSame(a2.getBi3(), b3);
assertEquals(b1.getBi3s(), Arrays.asList());
assertEquals(b1.getBi3List(), Arrays.asList());
assertEquals(b2.getBi3s(), Arrays.asList());
assertEquals(b2.getBi3List(), Arrays.asList());
assertEquals(b3.getBi3s(), Arrays.asList(a2));
assertEquals(b3.getBi3List(), Arrays.asList(a2));
a1.setBi3(b3);
a3.setBi3(b3);
assertSame(a1.getBi3(), b3);
assertSame(a2.getBi3(), b3);
assertSame(a3.getBi3(), b3);
assertEquals(b1.getBi3s(), Arrays.asList());
assertEquals(b1.getBi3List(), Arrays.asList());
assertEquals(b2.getBi3s(), Arrays.asList());
assertEquals(b2.getBi3List(), Arrays.asList());
assertEquals(b3.getBi3s(), Arrays.asList(a2, a1, a3));
assertEquals(b3.getBi3List(), Arrays.asList(a2, a1, a3));
a2.setBi3(b1);
assertSame(a1.getBi3(), b3);
assertSame(a2.getBi3(), b1);
assertSame(a3.getBi3(), b3);
assertEquals(b1.getBi3s(), Arrays.asList(a2));
assertEquals(b1.getBi3List(), Arrays.asList(a2));
assertEquals(b2.getBi3s(), Arrays.asList());
assertEquals(b2.getBi3List(), Arrays.asList());
assertEquals(b3.getBi3s(), Arrays.asList(a1, a3));
assertEquals(b3.getBi3List(), Arrays.asList(a1, a3));
try {
a2.setBi3(null);
fail("should throw an exception");
} catch (Exception e) {
// OK
}
}
/**
* rel A.Bi4? <-> B.Bi4;
*/
@Test
void testBi41() {
// Init
setup();
a1.setBi4(b1);
a2.setBi4(b2);
// Change
a2.setBi4(b1);
assertNull(a1.getBi4());
assertSame(a2.getBi4(), b1);
assertSame(b1.getBi4(), a2);
assertNull(b2.getBi4());
}
@Test
void testBi42() {
// Init
setup();
a1.setBi4(b2);
// Change
a2.setBi4(b2);
assertNull(a1.getBi4());
assertSame(a2.getBi4(), b2);
assertNull(b1.getBi4());
assertSame(b2.getBi4(), a2);
}
/**
* rel A.Bi5? <-> B.Bi5?;
*/
@Test
void testBi51() {
// Init
setup();
a1.setBi5(b1);
a2.setBi5(b2);
// Change
a2.setBi5(b1);
assertNull(a1.getBi5());
assertSame(a2.getBi5(), b1);
assertSame(b1.getBi5(), a2);
assertNull(b2.getBi5());
}
@Test
void testBi52() {
// Init
setup();
a1.setBi5(b2);
// Change
a2.setBi5(b2);
assertNull(a1.getBi5());
assertSame(a2.getBi5(), b2);
assertNull(b1.getBi5());
assertSame(b2.getBi5(), a2);
}
/**
* rel A.Bi6? <-> B.Bi6*;
*/
@Test
void testBi6() {
setup();
a2.setBi6(b2);
assertNull(a1.getBi6());
assertSame(a2.getBi6(), b2);
assertEquals(b1.getBi6s(), Arrays.asList());
assertEquals(b1.getBi6List(), Arrays.asList());
assertEquals(b2.getBi6s(), Arrays.asList(a2));
assertEquals(b2.getBi6List(), Arrays.asList(a2));
assertEquals(b3.getBi6s(), Arrays.asList());
assertEquals(b3.getBi6List(), Arrays.asList());
a2.setBi6(b3);
assertNull(a1.getBi6());
assertSame(a2.getBi6(), b3);
assertEquals(b1.getBi6s(), Arrays.asList());
assertEquals(b1.getBi6List(), Arrays.asList());
assertEquals(b2.getBi6s(), Arrays.asList());
assertEquals(b2.getBi6List(), Arrays.asList());
assertEquals(b3.getBi6s(), Arrays.asList(a2));
assertEquals(b3.getBi6List(), Arrays.asList(a2));
a1.setBi6(b3);
a3.setBi6(b3);
assertSame(a1.getBi6(), b3);
assertSame(a2.getBi6(), b3);
assertSame(a3.getBi6(), b3);
assertEquals(b1.getBi6s(), Arrays.asList());
assertEquals(b1.getBi6List(), Arrays.asList());
assertEquals(b2.getBi6s(), Arrays.asList());
assertEquals(b2.getBi6List(), Arrays.asList());
assertEquals(b3.getBi6s(), Arrays.asList(a2, a1, a3));
assertEquals(b3.getBi6List(), Arrays.asList(a2, a1, a3));
a2.setBi6(b1);
assertSame(a1.getBi6(), b3);
assertSame(a2.getBi6(), b1);
assertSame(a3.getBi6(), b3);
assertEquals(b1.getBi6s(), Arrays.asList(a2));
assertEquals(b1.getBi6List(), Arrays.asList(a2));
assertEquals(b2.getBi6s(), Arrays.asList());
assertEquals(b2.getBi6List(), Arrays.asList());
assertEquals(b3.getBi6s(), Arrays.asList(a1, a3));
assertEquals(b3.getBi6List(), Arrays.asList(a1, a3));
a2.clearBi6();
assertSame(a1.getBi6(), b3);
assertNull(a2.getBi6());
assertSame(a3.getBi6(), b3);
assertEquals(b1.getBi6s(), Arrays.asList());
assertEquals(b1.getBi6List(), Arrays.asList());
assertEquals(b2.getBi6s(), Arrays.asList());
assertEquals(b2.getBi6List(), Arrays.asList());
assertEquals(b3.getBi6s(), Arrays.asList(a1, a3));
assertEquals(b3.getBi6List(), Arrays.asList(a1, a3));
assertTrue(a1.hasBi6());
assertFalse(a2.hasBi6());
assertTrue(a3.hasBi6());
}
/**
* rel A.Bi7* <-> B.Bi7;
*/
@Test
void testBi7() {
setup();
a2.addBi7(b2);
assertEquals(a1.getBi7s(), Arrays.asList());
assertEquals(a1.getBi7List(), Arrays.asList());
assertEquals(a2.getBi7s(), Arrays.asList(b2));
assertEquals(a2.getBi7List(), Arrays.asList(b2));
assertNull(b1.getBi7());
assertSame(b2.getBi7(), a2);
assertNull(b3.getBi7());
a2.addBi7(b3);
a1.addBi7(b2);
assertEquals(a1.getBi7s(), Arrays.asList(b2));
assertEquals(a1.getBi7List(), Arrays.asList(b2));
assertEquals(a2.getBi7s(), Arrays.asList(b3));
assertEquals(a2.getBi7List(), Arrays.asList(b3));
assertNull(b1.getBi7());
assertSame(b2.getBi7(), a1);
assertSame(b3.getBi7(), a2);
a1.addBi7(b1);
assertEquals(a1.getBi7s(), Arrays.asList(b2, b1));
assertEquals(a1.getBi7List(), Arrays.asList(b2, b1));
assertEquals(a2.getBi7s(), Arrays.asList(b3));
assertEquals(a2.getBi7List(), Arrays.asList(b3));
assertSame(b1.getBi7(), a1);
assertSame(b2.getBi7(), a1);
assertSame(b3.getBi7(), a2);
a1.addBi7(b1);
assertEquals(a1.getBi7s(), Arrays.asList(b2, b1));
assertEquals(a1.getBi7List(), Arrays.asList(b2, b1));
assertEquals(a2.getBi7s(), Arrays.asList(b3));
assertEquals(a2.getBi7List(), Arrays.asList(b3));
assertSame(b1.getBi7(), a1);
assertSame(b2.getBi7(), a1);
assertSame(b3.getBi7(), a2);
a1.removeBi7(b1);
assertEquals(a1.getBi7s(), Arrays.asList(b2));
assertEquals(a1.getBi7List(), Arrays.asList(b2));
assertEquals(a2.getBi7s(), Arrays.asList(b3));
assertEquals(a2.getBi7List(), Arrays.asList(b3));
assertNull(b1.getBi7());
assertSame(b2.getBi7(), a1);
assertSame(b3.getBi7(), a2);
}
/**
* rel A.Bi8* <-> B.Bi8?;
*/
@Test
void testBi8() {
setup();
a2.addBi8(b2);
assertEquals(a1.getBi8s(), Arrays.asList());
assertEquals(a1.getBi8List(), Arrays.asList());
assertEquals(a2.getBi8s(), Arrays.asList(b2));
assertEquals(a2.getBi8List(), Arrays.asList(b2));
assertNull(b1.getBi8());
assertSame(b2.getBi8(), a2);
assertNull(b3.getBi8());
a2.addBi8(b3);
a1.addBi8(b2);
assertEquals(a1.getBi8s(), Arrays.asList(b2));
assertEquals(a1.getBi8List(), Arrays.asList(b2));
assertEquals(a2.getBi8s(), Arrays.asList(b3));
assertEquals(a2.getBi8List(), Arrays.asList(b3));
assertNull(b1.getBi8());
assertSame(b2.getBi8(), a1);
assertSame(b3.getBi8(), a2);
a1.addBi8(b1);
assertEquals(a1.getBi8s(), Arrays.asList(b2, b1));
assertEquals(a1.getBi8List(), Arrays.asList(b2, b1));
assertEquals(a2.getBi8s(), Arrays.asList(b3));
assertEquals(a2.getBi8List(), Arrays.asList(b3));
assertSame(b1.getBi8(), a1);
assertSame(b2.getBi8(), a1);
assertSame(b3.getBi8(), a2);
a1.addBi8(b1);
assertEquals(a1.getBi8s(), Arrays.asList(b2, b1));
assertEquals(a1.getBi8List(), Arrays.asList(b2, b1));
assertEquals(a2.getBi8s(), Arrays.asList(b3));
assertEquals(a2.getBi8List(), Arrays.asList(b3));
assertSame(b1.getBi8(), a1);
assertSame(b2.getBi8(), a1);
assertSame(b3.getBi8(), a2);
a1.removeBi8(b1);
assertEquals(a1.getBi8s(), Arrays.asList(b2));
assertEquals(a1.getBi8List(), Arrays.asList(b2));
assertEquals(a2.getBi8s(), Arrays.asList(b3));
assertEquals(a2.getBi8List(), Arrays.asList(b3));
assertNull(b1.getBi8());
assertSame(b2.getBi8(), a1);
assertSame(b3.getBi8(), a2);
}
/**
* rel A.Bi9* <-> B.Bi9*;
*/
@Test
void testBi9() {
setup();
a1.addBi9(b1);
a1.addBi9(b2);
assertEquals(a1.getBi9s(), Arrays.asList(b1, b2));
assertEquals(a1.getBi9List(), Arrays.asList(b1, b2));
assertEquals(a2.getBi9s(), Arrays.asList());
assertEquals(a2.getBi9List(), Arrays.asList());
assertEquals(a3.getBi9s(), Arrays.asList());