mirror of
https://gitlab.kit.edu/uskyk/typicalc.git
synced 2024-11-08 18:30:42 +00:00
partial LatexCreatorConstraintsTest
This commit is contained in:
parent
8446bc5a04
commit
73802e50fb
@ -75,7 +75,7 @@ public class LatexCreatorConstraints implements StepVisitor {
|
||||
private String createSingleConstraint(Constraint constraint) {
|
||||
String firstType = new LatexCreatorType(constraint.getFirstType()).getLatex();
|
||||
String secondType = new LatexCreatorType(constraint.getSecondType()).getLatex();
|
||||
return firstType + SPACE + EQUALS + SPACE + secondType;
|
||||
return firstType + EQUALS + secondType;
|
||||
}
|
||||
|
||||
private void addConstraint(InferenceStep step) {
|
||||
|
@ -0,0 +1,82 @@
|
||||
package edu.kit.typicalc.view.content.typeinferencecontent.latexcreator;
|
||||
|
||||
import edu.kit.typicalc.model.Model;
|
||||
import edu.kit.typicalc.model.ModelImpl;
|
||||
import edu.kit.typicalc.model.TypeInfererInterface;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import static edu.kit.typicalc.view.content.typeinferencecontent.latexcreator.LatexCreatorConstants.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
class LatexCreatorConstraintsTest {
|
||||
private static final String EMPTY_CONSTRAINT_SET =
|
||||
ALIGN_BEGIN + CONSTRAINT_SET + EQUALS + LATEX_CURLY_LEFT + LATEX_CURLY_RIGHT + ALIGN_END;
|
||||
|
||||
private final Model model = new ModelImpl();
|
||||
private TypeInfererInterface typeInferer;
|
||||
|
||||
// todo tests should test all of getEverything, not only the first 2 parts
|
||||
@Test
|
||||
void singleVarDefaultConstraintTest() {
|
||||
typeInferer = model.getTypeInferer("x", new HashMap<>()).unwrap();
|
||||
List<String> expected = new LatexCreatorConstraints(typeInferer).getEverything();
|
||||
|
||||
List<String> actual = List.of(EMPTY_CONSTRAINT_SET,
|
||||
ALIGN_BEGIN + CONSTRAINT_SET + EQUALS + LATEX_CURLY_LEFT + TREE_VARIABLE + "_{1}" + EQUALS
|
||||
+ GENERATED_ASSUMPTION_VARIABLE + "_{1}" + LATEX_CURLY_RIGHT + ALIGN_END);
|
||||
|
||||
for (int i = 0; i < actual.size(); i++) {
|
||||
assertEquals(actual.get(i), expected.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void singleAbsDefaultConstraintTest() {
|
||||
typeInferer = model.getTypeInferer("λx.y", new HashMap<>()).unwrap();
|
||||
List<String> expected = new LatexCreatorConstraints(typeInferer).getEverything();
|
||||
|
||||
List<String> actual = List.of(EMPTY_CONSTRAINT_SET,
|
||||
ALIGN_BEGIN + CONSTRAINT_SET + EQUALS + LATEX_CURLY_LEFT + TREE_VARIABLE + "_{1}" + EQUALS
|
||||
+ TREE_VARIABLE + "_{2}" + SPACE + RIGHT_ARROW + SPACE + TREE_VARIABLE + "_{3}"
|
||||
+ LATEX_CURLY_RIGHT + ALIGN_END);
|
||||
|
||||
for (int i = 0; i < actual.size(); i++) {
|
||||
assertEquals(actual.get(i), expected.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void singleAppConstraintTest() {
|
||||
typeInferer = model.getTypeInferer("x y", new HashMap<>()).unwrap();
|
||||
List<String> expected = new LatexCreatorConstraints(typeInferer).getEverything();
|
||||
|
||||
List<String> actual = List.of(EMPTY_CONSTRAINT_SET,
|
||||
ALIGN_BEGIN + CONSTRAINT_SET + EQUALS + LATEX_CURLY_LEFT + TREE_VARIABLE + "_{2}" + EQUALS
|
||||
+ TREE_VARIABLE + "_{3}" + SPACE + RIGHT_ARROW + SPACE + TREE_VARIABLE + "_{1}"
|
||||
+ LATEX_CURLY_RIGHT + ALIGN_END);
|
||||
|
||||
for (int i = 0; i < actual.size(); i++) {
|
||||
assertEquals(actual.get(i), expected.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void singleConstConstraintTest() {
|
||||
typeInferer = model.getTypeInferer("5", new HashMap<>()).unwrap();
|
||||
List<String> expected = new LatexCreatorConstraints(typeInferer).getEverything();
|
||||
|
||||
List<String> actual = List.of(EMPTY_CONSTRAINT_SET,
|
||||
ALIGN_BEGIN + CONSTRAINT_SET + EQUALS + LATEX_CURLY_LEFT + TREE_VARIABLE + "_{1}" + EQUALS
|
||||
+ MONO_TEXT + "{int}" + LATEX_CURLY_RIGHT + ALIGN_END);
|
||||
|
||||
for (int i = 0; i < actual.size(); i++) {
|
||||
assertEquals(actual.get(i), expected.get(i));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user