mirror of
https://gitlab.kit.edu/uskyk/typicalc.git
synced 2024-11-10 03:10:44 +00:00
LetStepDefault test
This commit is contained in:
parent
08d19ffdc6
commit
f46997d359
@ -0,0 +1,72 @@
|
||||
package edu.kit.typicalc.model.step;
|
||||
|
||||
import edu.kit.typicalc.model.Conclusion;
|
||||
import edu.kit.typicalc.model.Constraint;
|
||||
import edu.kit.typicalc.model.TypeVariableFactory;
|
||||
import edu.kit.typicalc.model.term.IntegerTerm;
|
||||
import edu.kit.typicalc.model.term.VarTerm;
|
||||
import edu.kit.typicalc.model.type.NamedType;
|
||||
import edu.kit.typicalc.model.type.TypeAbstraction;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class LetStepDefaultTest {
|
||||
static InferenceStep premise = null;
|
||||
static Conclusion conclusion = null;
|
||||
static Constraint constraint = null;
|
||||
static NamedType namedType = null;
|
||||
static TypeAbstraction typeAbstraction = null;
|
||||
static TestTypeInfererLet typeInferer = null;
|
||||
@BeforeAll
|
||||
static void setUp() {
|
||||
Map<VarTerm, TypeAbstraction> map = new HashMap<>();
|
||||
VarTerm term = new VarTerm("test");
|
||||
namedType = new NamedType("testType");
|
||||
typeAbstraction = new TypeAbstraction(namedType);
|
||||
map.put(term, typeAbstraction);
|
||||
IntegerTerm integerTerm = new IntegerTerm(1);
|
||||
conclusion = new Conclusion(map, integerTerm, namedType);
|
||||
NamedType type1 = new NamedType("a");
|
||||
NamedType type2 = new NamedType("b");
|
||||
constraint = new Constraint(type1, type2);
|
||||
premise = new ConstStepDefault(conclusion, constraint);
|
||||
typeInferer = new TestTypeInfererLet(integerTerm, map, new TestTypeVariableFactory());
|
||||
}
|
||||
@Test
|
||||
void equalsTest() {
|
||||
LetStepDefault step1 = new LetStepDefault(conclusion, constraint, premise, typeInferer);
|
||||
LetStepDefault step2 = new LetStepDefault(conclusion, constraint, premise, typeInferer);
|
||||
LetStepDefault step3 = new LetStepDefault(conclusion, null, premise, typeInferer);
|
||||
LetStepDefault step4 = new LetStepDefault(conclusion, constraint, null, typeInferer);
|
||||
LetStepDefault step5 = new LetStepDefault(conclusion, constraint, premise, null);
|
||||
|
||||
assertEquals(step1, step1);
|
||||
assertEquals(step1, step2);
|
||||
assertNotEquals(new EmptyStep(), step1);
|
||||
assertNotEquals(step1, null);
|
||||
assertNotEquals(step1, step3);
|
||||
assertNotEquals(step1, step4);
|
||||
assertNotEquals(step1, step5);
|
||||
|
||||
}
|
||||
@Test
|
||||
void hashCodeTest() {
|
||||
LetStepDefault step1 = new LetStepDefault(conclusion, constraint, premise, typeInferer);
|
||||
LetStepDefault step2 = new LetStepDefault(conclusion, constraint, premise, typeInferer);
|
||||
|
||||
assertEquals(step1.hashCode(), step2.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void acceptTest() {
|
||||
TestStepVisitor testStepVisitor = new TestStepVisitor();
|
||||
LetStepDefault step = new LetStepDefault(conclusion, constraint, premise, typeInferer);
|
||||
step.accept(testStepVisitor);
|
||||
assertEquals("LetDef", testStepVisitor.visited);
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package edu.kit.typicalc.model.step;
|
||||
|
||||
import edu.kit.typicalc.model.TypeInfererLet;
|
||||
import edu.kit.typicalc.model.TypeVariableFactory;
|
||||
import edu.kit.typicalc.model.term.LambdaTerm;
|
||||
import edu.kit.typicalc.model.term.VarTerm;
|
||||
import edu.kit.typicalc.model.type.TypeAbstraction;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class TestTypeInfererLet extends TypeInfererLet {
|
||||
public TestTypeInfererLet(LambdaTerm term, Map<VarTerm, TypeAbstraction> map, TypeVariableFactory factory) {
|
||||
super(term, map, factory);
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package edu.kit.typicalc.model.step;
|
||||
|
||||
import edu.kit.typicalc.model.TypeVariableFactory;
|
||||
import edu.kit.typicalc.model.type.TypeVariableKind;
|
||||
|
||||
public class TestTypeVariableFactory extends TypeVariableFactory {
|
||||
public TestTypeVariableFactory() {
|
||||
super(TypeVariableKind.USER_INPUT);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user