StepFactoryWithLet test

This commit is contained in:
uogau 2021-02-08 03:16:08 +01:00
parent 2839bb6637
commit d4e9d3b566
3 changed files with 111 additions and 7 deletions

17
pom.xml
View File

@ -149,6 +149,8 @@
</dependency>
</dependencies>
<build>
<defaultGoal>spring-boot:run</defaultGoal>
<plugins>
@ -204,6 +206,21 @@
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.6</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<!-- attached to Maven test phase -->
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>

View File

@ -1,11 +1,12 @@
package edu.kit.typicalc.model.step;
import edu.kit.typicalc.model.*;
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.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.BeforeAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
@ -36,7 +37,7 @@ class StepFactoryDefaultTest {
}
@Test
void createAbsStep() {
void createAbsStepTest() {
StepFactoryDefault factory = new StepFactoryDefault();
AbsStepDefault step = factory.createAbsStep(premise, conclusion, constraint);
assertEquals(premise, step.getPremise());
@ -45,7 +46,7 @@ class StepFactoryDefaultTest {
}
@Test
void createAppStep() {
void createAppStepTest() {
StepFactoryDefault factory = new StepFactoryDefault();
AppStepDefault step = factory.createAppStep(premise, premise, conclusion, constraint);
assertEquals(premise, step.getPremise1());
@ -55,7 +56,7 @@ class StepFactoryDefaultTest {
}
@Test
void createConstStep() {
void createConstStepTest() {
StepFactoryDefault factory = new StepFactoryDefault();
ConstStepDefault step = factory.createConstStep(conclusion, constraint);
assertEquals(conclusion, step.getConclusion());
@ -63,7 +64,7 @@ class StepFactoryDefaultTest {
}
@Test
void createVarStep() {
void createVarStepTest() {
StepFactoryDefault factory = new StepFactoryDefault();
VarStepDefault step = factory.createVarStep(typeAbstraction, namedType, conclusion, constraint);
assertEquals(typeAbstraction, step.getTypeAbsInPremise());
@ -73,7 +74,7 @@ class StepFactoryDefaultTest {
}
@Test
void createLetStep() {
void createLetStepTest() {
StepFactoryDefault factory = new StepFactoryDefault();
boolean thrown = false;
try {

View File

@ -0,0 +1,86 @@
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 static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import java.util.HashMap;
import java.util.Map;
class StepFactoryWithLetTest {
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 createAbsStepTest() {
StepFactoryWithLet factory = new StepFactoryWithLet();
AbsStepWithLet step = factory.createAbsStep(premise, conclusion, constraint);
assertEquals(premise, step.getPremise());
assertEquals(conclusion, step.getConclusion());
assertEquals(constraint, step.getConstraint());
}
@Test
void createAppStepTest() {
StepFactoryWithLet factory = new StepFactoryWithLet();
AppStepDefault step = factory.createAppStep(premise, premise, conclusion, constraint);
assertEquals(premise, step.getPremise1());
assertEquals(premise, step.getPremise2());
assertEquals(conclusion, step.getConclusion());
assertEquals(constraint, step.getConstraint());
}
@Test
void createConstStepTest() {
StepFactoryWithLet factory = new StepFactoryWithLet();
ConstStepDefault step = factory.createConstStep(conclusion, constraint);
assertEquals(conclusion, step.getConclusion());
assertEquals(constraint, step.getConstraint());
}
@Test
void createVarStepTest() {
StepFactoryWithLet factory = new StepFactoryWithLet();
VarStepWithLet step = factory.createVarStep(typeAbstraction, namedType, conclusion, constraint);
assertEquals(typeAbstraction, step.getTypeAbsInPremise());
assertEquals(namedType, step.getInstantiatedTypeAbs());
assertEquals(conclusion, step.getConclusion());
assertEquals(constraint, step.getConstraint());
}
@Test
void createLetStepTest() {
StepFactoryWithLet factory = new StepFactoryWithLet();
LetStep step = factory.createLetStep(conclusion, constraint, premise, null);
assertEquals(premise, step.getPremise());
assertNull(step.getTypeInferer());
assertEquals(conclusion, step.getConclusion());
assertEquals(constraint, step.getConstraint());
}
}