From d4e9d3b56683dab013ab279082cb71f267efc707 Mon Sep 17 00:00:00 2001 From: uogau Date: Mon, 8 Feb 2021 03:16:08 +0100 Subject: [PATCH] StepFactoryWithLet test --- pom.xml | 17 ++++ .../model/step/StepFactoryDefaultTest.java | 15 ++-- .../model/step/StepFactoryWithLetTest.java | 86 +++++++++++++++++++ 3 files changed, 111 insertions(+), 7 deletions(-) create mode 100644 src/test/java/edu/kit/typicalc/model/step/StepFactoryWithLetTest.java diff --git a/pom.xml b/pom.xml index 4f9c5fb..d53ccfb 100644 --- a/pom.xml +++ b/pom.xml @@ -149,6 +149,8 @@ + + spring-boot:run @@ -204,6 +206,21 @@ org.jacoco jacoco-maven-plugin 0.8.6 + + + + prepare-agent + + + + + report + test + + report + + + diff --git a/src/test/java/edu/kit/typicalc/model/step/StepFactoryDefaultTest.java b/src/test/java/edu/kit/typicalc/model/step/StepFactoryDefaultTest.java index 3b80bb1..6192989 100644 --- a/src/test/java/edu/kit/typicalc/model/step/StepFactoryDefaultTest.java +++ b/src/test/java/edu/kit/typicalc/model/step/StepFactoryDefaultTest.java @@ -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 { diff --git a/src/test/java/edu/kit/typicalc/model/step/StepFactoryWithLetTest.java b/src/test/java/edu/kit/typicalc/model/step/StepFactoryWithLetTest.java new file mode 100644 index 0000000..10b1640 --- /dev/null +++ b/src/test/java/edu/kit/typicalc/model/step/StepFactoryWithLetTest.java @@ -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 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()); + } +} \ No newline at end of file