Tests for Substitution, Constraint

This commit is contained in:
Johanna Stuber 2021-01-30 13:13:51 +01:00
parent 1b2f1a1cd6
commit 9affbb4807
4 changed files with 78 additions and 1 deletions

View File

@ -127,6 +127,13 @@
<version>5.7.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier</artifactId>
<version>3.5.2</version>
<scope>test</scope>
</dependency>
<!-- need these for IntelliJ -->
<dependency>
<groupId>org.junit.platform</groupId>

View File

@ -0,0 +1,32 @@
package edu.kit.typicalc.model;
import edu.kit.typicalc.model.type.Type;
import edu.kit.typicalc.model.type.TypeVariable;
import edu.kit.typicalc.model.type.TypeVaribaleKind;
import nl.jqno.equalsverifier.EqualsVerifier;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class ConstraintTest {
private static final Type type1 = new TypeVariable(TypeVaribaleKind.USER_INPUT, 1);
private static final Type type2 = new TypeVariable(TypeVaribaleKind.TREE, 2);
@Test
void equalsTest() {
EqualsVerifier.forClass(Constraint.class).usingGetClass().verify();
}
@Test
void getFirstTest() {
Constraint con = new Constraint(type1,type2);
assertEquals(type1, con.getFirstType());
}
@Test
void getSecondTest() {
Constraint con = new Constraint(type1,type2);
assertEquals(type2, con.getSecondType());
}
}

View File

@ -0,0 +1,32 @@
package edu.kit.typicalc.model;
import edu.kit.typicalc.model.type.Type;
import edu.kit.typicalc.model.type.TypeVariable;
import edu.kit.typicalc.model.type.TypeVaribaleKind;
import nl.jqno.equalsverifier.EqualsVerifier;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
class SubstitutionTest {
private static final TypeVariable var = new TypeVariable(TypeVaribaleKind.USER_INPUT, 1);
private static final Type type = new TypeVariable(TypeVaribaleKind.TREE, 2);
@Test
void equalsTest() {
EqualsVerifier.forClass(Substitution.class).usingGetClass().verify();
}
@Test
void getVariableTest() {
Substitution sub = new Substitution(var,type);
assertEquals(var, sub.getVariable());
}
@Test
void getTypeTest() {
Substitution sub = new Substitution(var,type);
assertEquals(type, sub.getType());
}
}

View File

@ -1,11 +1,17 @@
package edu.kit.typicalc.model.type;
import nl.jqno.equalsverifier.EqualsVerifier;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
class FunctionTypeTest {
@Test
void equalsTest() {
EqualsVerifier.forClass(FunctionType.class).usingGetClass().verify();
}
@Test
void substitute() {
TypeVariable typeVariable1 = new TypeVariable(TypeVaribaleKind.USER_INPUT, 1);