mirror of
https://gitlab.kit.edu/uskyk/typicalc.git
synced 2024-11-10 03:10:44 +00:00
AbsStepDefault test
This commit is contained in:
parent
8ffcac164a
commit
addbe90dcf
@ -0,0 +1,65 @@
|
||||
package edu.kit.typicalc.model.step;
|
||||
|
||||
import edu.kit.typicalc.model.Conclusion;
|
||||
import edu.kit.typicalc.model.Constraint;
|
||||
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.Test;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class AbsStepDefaultTest {
|
||||
static InferenceStep premise = null;
|
||||
static Conclusion conclusion = null;
|
||||
static Constraint constraint = null;
|
||||
static NamedType namedType = null;
|
||||
static TypeAbstraction typeAbstraction = 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);
|
||||
}
|
||||
@Test
|
||||
void equalsTest() {
|
||||
AbsStepDefault step1 = new AbsStepDefault(premise, conclusion, constraint);
|
||||
AbsStepDefault step2 = new AbsStepDefault(premise, conclusion, constraint);
|
||||
AbsStepDefault step3 = new AbsStepDefault(premise, conclusion, null);
|
||||
|
||||
assertEquals(step1, step1);
|
||||
assertEquals(step1, step2);
|
||||
assertNotEquals(null, step1);
|
||||
assertNotEquals(step1, step3);
|
||||
|
||||
}
|
||||
@Test
|
||||
void hashCodeTest() {
|
||||
AbsStepDefault step1 = new AbsStepDefault(premise, conclusion, constraint);
|
||||
AbsStepDefault step2 = new AbsStepDefault(premise, conclusion, constraint);
|
||||
|
||||
assertEquals(step1.hashCode(), step2.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void acceptTest() {
|
||||
TestStepVisitor testStepVisitor = new TestStepVisitor();
|
||||
AbsStepDefault step = new AbsStepDefault(premise, conclusion, constraint);
|
||||
step.accept(testStepVisitor);
|
||||
assertEquals("AbsDef", testStepVisitor.visited);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package edu.kit.typicalc.model.step;
|
||||
|
||||
public class TestStepVisitor implements StepVisitor {
|
||||
public String visited = "";
|
||||
@Override
|
||||
public void visit(AbsStepDefault absD) {
|
||||
visited = "AbsDef";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(AbsStepWithLet absL) {
|
||||
visited = "AbsLet";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(AppStepDefault appD) {
|
||||
visited = "AppDef";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ConstStepDefault constD) {
|
||||
visited = "ConstDef";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(VarStepDefault varD) {
|
||||
visited = "VarDef";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(VarStepWithLet varL) {
|
||||
visited = "VarLet";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(LetStepDefault letD) {
|
||||
visited = "LetDef";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(EmptyStep empty) {
|
||||
visited = "empty";
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user