diff --git a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/LatexCreatorConstraints.java b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/LatexCreatorConstraints.java index b98e418..3c5bffb 100644 --- a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/LatexCreatorConstraints.java +++ b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/LatexCreatorConstraints.java @@ -250,6 +250,7 @@ public class LatexCreatorConstraints implements StepVisitor { latex.append(BRACKET_RIGHT); latex.append(LATEX_NEW_LINE); } + latex.delete(latex.length() - LATEX_NEW_LINE.length(), latex.length()); latex.append(SPLIT_END); if (error.isPresent()) { latex.append(LATEX_NEW_LINE + AMPERSAND); @@ -266,7 +267,6 @@ public class LatexCreatorConstraints implements StepVisitor { latex.append(constraintSets); latex.append(AMPERSAND + SPLIT_BEGIN); latex.append(generateUnificationName()); - latex.append(SPACE); latex.append(BRACKET_LEFT); typeInferer.getMGU().ifPresent(mgu -> mgu.forEach(substitution -> { latex.append(AMPERSAND); diff --git a/src/test/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/LatexCreatorConstraintsTest.java b/src/test/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/LatexCreatorConstraintsTest.java index 993186a..9f87124 100644 --- a/src/test/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/LatexCreatorConstraintsTest.java +++ b/src/test/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/LatexCreatorConstraintsTest.java @@ -24,10 +24,27 @@ class LatexCreatorConstraintsTest { typeInferer = model.getTypeInferer("x", new HashMap<>()).unwrap(); List expected = new LatexCreatorConstraints(typeInferer).getEverything(); - List actual = List.of(EMPTY_CONSTRAINT_SET, - ALIGN_BEGIN + AMPERSAND + CONSTRAINT_SET + EQUALS + LATEX_CURLY_LEFT + TREE_VARIABLE + "_{1}" + EQUALS - + GENERATED_ASSUMPTION_VARIABLE + "_{1}" + LATEX_CURLY_RIGHT + ALIGN_END); + String constraintSet = AMPERSAND + CONSTRAINT_SET + EQUALS + LATEX_CURLY_LEFT + TREE_VARIABLE + "_{1}" + EQUALS + + GENERATED_ASSUMPTION_VARIABLE + "_{1}" + LATEX_CURLY_RIGHT; + String mguStart = LATEX_NEW_LINE + AMPERSAND + SPLIT_BEGIN + SIGMA + COLON + EQUALS + MGU + PAREN_LEFT + + CONSTRAINT_SET + PAREN_RIGHT; + + String mgu = "" + EQUALS + BRACKET_LEFT + AMPERSAND + TREE_VARIABLE + "_{1}" + + SUBSTITUTION_SIGN + GENERATED_ASSUMPTION_VARIABLE + "_{1}" + BRACKET_RIGHT + SPLIT_END; + + List actual = List.of(EMPTY_CONSTRAINT_SET, + ALIGN_BEGIN + constraintSet + ALIGN_END, + ALIGN_BEGIN + constraintSet + mguStart + EQUALS + UNIFY + PAREN_LEFT + LATEX_CURLY_LEFT + AMPERSAND + + TREE_VARIABLE + "_{1}" + EQUALS + GENERATED_ASSUMPTION_VARIABLE + "_{1}" + PAREN_RIGHT + + LATEX_CURLY_RIGHT + SPLIT_END + ALIGN_END, + ALIGN_BEGIN + constraintSet + mguStart + mgu + ALIGN_END, + ALIGN_BEGIN + constraintSet + mguStart + mgu + ALIGN_END, + ALIGN_BEGIN + constraintSet + mguStart + mgu + LATEX_NEW_LINE + AMPERSAND + SIGMA + PAREN_LEFT + + TREE_VARIABLE + "_{1}" + PAREN_RIGHT + EQUALS + GENERATED_ASSUMPTION_VARIABLE + + "_{1}" + ALIGN_END); + + assertEquals(actual.size(), expected.size()); for (int i = 0; i < actual.size(); i++) { assertEquals(actual.get(i), expected.get(i)); }