From 83b7815a4790cb01bcc4fef65ccf56da539136a3 Mon Sep 17 00:00:00 2001 From: Johanna Stuber Date: Sun, 31 Jan 2021 00:24:33 +0100 Subject: [PATCH] Add assertion for constraints in TreeTest::VisitAbs() --- src/test/java/edu/kit/typicalc/model/TreeTest.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/test/java/edu/kit/typicalc/model/TreeTest.java b/src/test/java/edu/kit/typicalc/model/TreeTest.java index 77aa551..923c40d 100644 --- a/src/test/java/edu/kit/typicalc/model/TreeTest.java +++ b/src/test/java/edu/kit/typicalc/model/TreeTest.java @@ -63,16 +63,24 @@ class TreeTest { TypeVariable variable3 = new TypeVariable(TypeVariableKind.TREE, 3); Tree tree = new Tree(TYPE_ASSUMPTIONS, ABS); + Map varTypeAss = new HashMap<>(TYPE_ASSUMPTIONS); varTypeAss.put(VAR, new TypeAbstraction(variable2)); Conclusion varConclusion = new Conclusion(varTypeAss, VAR, variable3); + Constraint varConstraint = new Constraint(variable2, variable3); InferenceStep varStep = new VarStepDefault(new TypeAbstraction(variable2), variable2, varConclusion, - new Constraint(variable2, variable3)); + varConstraint); Conclusion conclusion = new Conclusion(TYPE_ASSUMPTIONS, ABS, tree.getFirstTypeVariable()); - InferenceStep expectedStep = new AbsStepDefault(varStep, conclusion, - new Constraint(tree.getFirstTypeVariable(), new FunctionType(variable2, variable3))); + Constraint absConstraint = new Constraint(tree.getFirstTypeVariable(), new FunctionType(variable2, variable3)); + InferenceStep expectedStep = new AbsStepDefault(varStep, conclusion, absConstraint); + assertEquals(expectedStep, tree.getFirstInferenceStep()); + + List constraints = new ArrayList<>(); + constraints.add(varConstraint); + constraints.add(absConstraint); + assertEquals(constraints, tree.getConstraints()); } @Test