mirror of
https://gitlab.kit.edu/uskyk/typicalc.git
synced 2024-11-08 18:30:42 +00:00
Update integration tests
This commit is contained in:
parent
301af06c69
commit
478cd97706
@ -12,8 +12,9 @@ import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
||||
import com.vaadin.flow.component.textfield.TextField;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Contains all the predefined type assumptions for the selected term as buttons.
|
||||
* Clicking on a button starts the type inference algorithm with the selected term and the selected type
|
||||
* assumptions.
|
||||
*/
|
||||
@CssImport("./styles/view/main/assumption-example-content.css")
|
||||
public class AssumptionExampleContent extends VerticalLayout {
|
||||
@ -48,6 +49,7 @@ public class AssumptionExampleContent extends VerticalLayout {
|
||||
Button button = new Button(assumptions);
|
||||
button.addClickListener(click -> forwardCallback.accept(assumptions.
|
||||
replace(getTranslation("root.emptySet"), StringUtils.EMPTY)));
|
||||
button.setId(assumptions);
|
||||
this.add(button);
|
||||
}
|
||||
}
|
||||
|
@ -16,15 +16,15 @@ root.exampleTerms=\
|
||||
let f = λx. let g = λy. y in g x in f 3,\
|
||||
let f = λx. let g = λy.5 5 in g x in f 3
|
||||
|
||||
root.λx.x=∅; x: int; y: bool
|
||||
root.λx.λy.yx=∅; x: int; y: bool
|
||||
root.λx.λy.y(xx)=∅; x: int; y: bool
|
||||
root.letfλx.gyyinf3=∅; g: a->b->a; g: int->int->bool; g: int->int->bool, y: bool; g: int->int->bool, y: τ₁
|
||||
root.letkλx.λy.xinka(kbc)=∅; a: τ₁, a: ∀τ₁.τ₁->int; b: a, a: int; b: bool; c: char
|
||||
root.(λx.xx)(λx.xx)=∅; x: bool
|
||||
root.(λx.λy.y(xy))(λz.λa.zga)=∅; g: bool; a: int, g: bool->int; g: ∀τ₂.τ₁->τ₂
|
||||
root.letfλx.letgλy.yingxinf3=∅; g: bool->int->bool
|
||||
root.letfλx.letgλy.55ingxinf3=∅; f: bool->int->bool
|
||||
root.λx.x=∅;x: int;y: bool
|
||||
root.λx.λy.yx=∅;x: int;y: bool
|
||||
root.λx.λy.y(xx)=∅;x: int;y: bool
|
||||
root.letfλx.gyyinf3=∅;g: a->b->a;g: int->int->bool;g: int->int->bool, y: bool;g: int->int->bool, y: τ₁
|
||||
root.letkλx.λy.xinka(kbc)=∅;a: τ₁;a: ∀τ₁.τ₁->int, b: a;a: int, b: bool, c: char
|
||||
root.(λx.xx)(λx.xx)=∅;x: bool
|
||||
root.(λx.λy.y(xy))(λz.λa.zga)=∅;g: bool;a: int, g: bool->int;g: ∀τ₂.τ₁->τ₂
|
||||
root.letfλx.letgλy.yingxinf3=∅;g: bool->int->bool
|
||||
root.letfλx.letgλy.55ingxinf3=∅;f: bool->int->bool
|
||||
|
||||
root.termGrammar=\u2329Term\u232A ::= (\u2329Term\u232A) | \u2329App\u232A | \u2329Abs\u232A | \
|
||||
\u2329Let\u232A | \u2329Var\u232A | \u2329Const\u232A <br> \
|
||||
|
@ -1,7 +1,5 @@
|
||||
package edu.kit.typicalc.view;
|
||||
|
||||
import com.vaadin.flow.component.button.testbench.ButtonElement;
|
||||
import com.vaadin.flow.component.orderedlayout.testbench.HorizontalLayoutElement;
|
||||
import com.vaadin.testbench.Parameters;
|
||||
import com.vaadin.testbench.commands.TestBenchCommandExecutor;
|
||||
import edu.kit.typicalc.view.pageobjects.*;
|
||||
@ -72,9 +70,9 @@ public class ScreenshotIT extends AbstractIT {
|
||||
@Test
|
||||
public void basicExecution() throws Exception {
|
||||
InputBarElement inputBar = $(InputBarElement.class).first();
|
||||
inputBar.setCurrentValue(IDENTITY_TERM);
|
||||
inputBar.setTerm(IDENTITY_TERM);
|
||||
|
||||
assertEquals(IDENTITY_TERM, inputBar.getCurrentValue());
|
||||
assertEquals(IDENTITY_TERM, inputBar.getTerm());
|
||||
|
||||
inputBar.typeInfer();
|
||||
TestBenchCommandExecutor executer = getCommandExecutor();
|
||||
@ -89,9 +87,9 @@ public class ScreenshotIT extends AbstractIT {
|
||||
@Test
|
||||
public void createPermalink() throws IOException {
|
||||
InputBarElement inputBar = $(InputBarElement.class).first();
|
||||
inputBar.setCurrentValue(LET_TERM);
|
||||
inputBar.setTerm(LET_TERM);
|
||||
|
||||
assertEquals(LET_TERM, inputBar.getCurrentValue());
|
||||
assertEquals(LET_TERM, inputBar.getTerm());
|
||||
|
||||
inputBar.typeInfer();
|
||||
TestBenchCommandExecutor executor = getCommandExecutor();
|
||||
@ -114,23 +112,26 @@ public class ScreenshotIT extends AbstractIT {
|
||||
|
||||
@Test
|
||||
public void chooseExample() throws IOException {
|
||||
TestBenchCommandExecutor executor = getCommandExecutor();
|
||||
|
||||
InputBarElement inputBar = $(InputBarElement.class).first();
|
||||
inputBar.openExampleDialog();
|
||||
|
||||
ExampleDialogElement exampleDialog = $(ExampleDialogElement.class).waitForFirst();
|
||||
String term = "λx.x";
|
||||
exampleDialog.insertExample(term);
|
||||
|
||||
matches.add(term.equals(inputBar.getCurrentValue()));
|
||||
|
||||
TestBenchCommandExecutor executor = getCommandExecutor();
|
||||
executor.waitForVaadin();
|
||||
|
||||
String typeAssumptions = "x: int";
|
||||
exampleDialog.insertAssumptions(typeAssumptions);
|
||||
executor.waitForVaadin();
|
||||
|
||||
matches.add(term.equals(inputBar.getTerm()));
|
||||
matches.add(typeAssumptions.equals(inputBar.getTypeAssumptions()));
|
||||
|
||||
// check that the example is copied to the input bar
|
||||
matches.add(testBench().compareScreen("chooseExample1"));
|
||||
|
||||
inputBar.typeInfer();
|
||||
executor.waitForVaadin();
|
||||
ControlPanelElement control = $(ControlPanelElement.class).waitForFirst();
|
||||
control.lastStep();
|
||||
executor.waitForVaadin();
|
||||
@ -150,27 +151,16 @@ public class ScreenshotIT extends AbstractIT {
|
||||
|
||||
InputBarElement inputBar = $(InputBarElement.class).first();
|
||||
String term = "λx. f x";
|
||||
inputBar.setCurrentValue(term);
|
||||
inputBar.setTerm(term);
|
||||
|
||||
// check if the correct term is entered
|
||||
matches.add(term.equals(inputBar.getCurrentValue()));
|
||||
|
||||
inputBar.openTypeAssumptionsArea();
|
||||
TypeAssumptionsAreaElement assumptionsArea = $(TypeAssumptionsAreaElement.class).waitForFirst();
|
||||
assumptionsArea.addTypeAssumption();
|
||||
executor.waitForVaadin();
|
||||
TypeAssumptionFieldElement assumptionField = assumptionsArea.getLastTypeAssumption();
|
||||
|
||||
String variable = "f";
|
||||
String type = "int -> y";
|
||||
assumptionField.setVariable(variable);
|
||||
assumptionField.setType(type);
|
||||
assumptionsArea.$(HorizontalLayoutElement.class).first().$(ButtonElement.class).last().focus();
|
||||
|
||||
executor.waitForVaadin();
|
||||
// check if type assumption is added correctly
|
||||
matches.add(testBench().compareScreen("exportLatexWithAssumptions1"));
|
||||
assumptionsArea.closeDialog();
|
||||
matches.add(term.equals(inputBar.getTerm()));
|
||||
|
||||
String typeAssumptions = "f: int -> y";
|
||||
inputBar.setTypeAssumptions(typeAssumptions);
|
||||
|
||||
// check if the correct type assumptions are entered
|
||||
matches.add(typeAssumptions.equals(inputBar.getTypeAssumptions()));
|
||||
|
||||
inputBar.typeInfer();
|
||||
executor.waitForVaadin();
|
||||
@ -193,10 +183,10 @@ public class ScreenshotIT extends AbstractIT {
|
||||
|
||||
InputBarElement inputBar = $(InputBarElement.class).first();
|
||||
String term = "λx. f x";
|
||||
inputBar.setCurrentValue(term);
|
||||
inputBar.setTerm(term);
|
||||
|
||||
// check if the correct term is entered
|
||||
Assert.assertEquals(term, inputBar.getCurrentValue());
|
||||
Assert.assertEquals(term, inputBar.getTerm());
|
||||
inputBar.typeInfer();
|
||||
|
||||
ControlPanelElement controlPanelElement = $(ControlPanelElement.class).first();
|
||||
@ -252,8 +242,8 @@ public class ScreenshotIT extends AbstractIT {
|
||||
InputBarElement inputBar = $(InputBarElement.class).first();
|
||||
String term = "λ5.x";
|
||||
|
||||
inputBar.setCurrentValue(term);
|
||||
assertEquals(term, inputBar.getCurrentValue());
|
||||
inputBar.setTerm(term);
|
||||
assertEquals(term, inputBar.getTerm());
|
||||
inputBar.typeInfer();
|
||||
executor.waitForVaadin();
|
||||
|
||||
|
@ -14,9 +14,13 @@ public class ExampleDialogElement extends DialogElement {
|
||||
/**
|
||||
* Click on an example of the example dialog.
|
||||
*
|
||||
* @param example the example
|
||||
* @param exampleTerm the example
|
||||
*/
|
||||
public void insertExample(String example) {
|
||||
$(VerticalLayoutElement.class).first().$(ButtonElement.class).id(example).click();
|
||||
public void insertExample(String exampleTerm) {
|
||||
$(VerticalLayoutElement.class).first().$(ButtonElement.class).id(exampleTerm).click();
|
||||
}
|
||||
|
||||
public void insertAssumptions(String exampleAssumptions) {
|
||||
$(VerticalLayoutElement.class).first().$(ButtonElement.class).id(exampleAssumptions).click();
|
||||
}
|
||||
}
|
||||
|
@ -19,21 +19,39 @@ public class InputBarElement extends HorizontalLayoutElement {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current value of the inputField.
|
||||
* Set the current value of the termInputField.
|
||||
*
|
||||
* @param value the value
|
||||
*/
|
||||
public void setCurrentValue(String value) {
|
||||
$(TextFieldElement.class).id("inputField").setValue(value);
|
||||
public void setTerm(String value) {
|
||||
$(TextFieldElement.class).id("term-input-field").setValue(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current value of the inputField.
|
||||
* Get the current value of the termInputField.
|
||||
*
|
||||
* @return the current value
|
||||
*/
|
||||
public String getCurrentValue() {
|
||||
return $(TextFieldElement.class).id("inputField").getValue();
|
||||
public String getTerm() {
|
||||
return $(TextFieldElement.class).id("term-input-field").getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current value of the assumptionInputField.
|
||||
*
|
||||
* @param assumptions the value
|
||||
*/
|
||||
public void setTypeAssumptions(String assumptions) {
|
||||
$(TextFieldElement.class).id("ass-input-field").setValue(assumptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current value of the assumptionInputField.
|
||||
*
|
||||
* @return the current value
|
||||
*/
|
||||
public String getTypeAssumptions() {
|
||||
return $(TextFieldElement.class).id("ass-input-field").getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,17 +0,0 @@
|
||||
package edu.kit.typicalc.view.pageobjects;
|
||||
|
||||
import com.vaadin.flow.component.orderedlayout.testbench.HorizontalLayoutElement;
|
||||
import com.vaadin.flow.component.textfield.testbench.TextFieldElement;
|
||||
import com.vaadin.testbench.annotations.Attribute;
|
||||
|
||||
@Attribute(name = "id", value = "typeAssumptionField")
|
||||
public class TypeAssumptionFieldElement extends HorizontalLayoutElement {
|
||||
|
||||
public void setVariable(String variable) {
|
||||
$(TextFieldElement.class).first().setValue(variable);
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
$(TextFieldElement.class).last().setValue(type);
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package edu.kit.typicalc.view.pageobjects;
|
||||
|
||||
import com.vaadin.flow.component.button.testbench.ButtonElement;
|
||||
import com.vaadin.flow.component.orderedlayout.testbench.HorizontalLayoutElement;
|
||||
import com.vaadin.flow.component.orderedlayout.testbench.VerticalLayoutElement;
|
||||
import com.vaadin.testbench.annotations.Attribute;
|
||||
|
||||
/**
|
||||
* Vaadin TestBench element for {@link edu.kit.typicalc.view.main.TypeAssumptionsArea}.
|
||||
*/
|
||||
@Attribute(name = "id", value = "assLayout")
|
||||
public class TypeAssumptionsAreaElement extends VerticalLayoutElement {
|
||||
|
||||
/**
|
||||
* Adds a new TypeAssumption.
|
||||
*/
|
||||
public void addTypeAssumption() {
|
||||
$(HorizontalLayoutElement.class).id("assButtons").$(ButtonElement.class).first().click();
|
||||
}
|
||||
|
||||
public TypeAssumptionFieldElement getLastTypeAssumption() {
|
||||
return $(VerticalLayoutElement.class).id("assContainer")
|
||||
.$(TypeAssumptionFieldElement.class).last();
|
||||
}
|
||||
|
||||
public void closeDialog() {
|
||||
$(HorizontalLayoutElement.class).first().$(ButtonElement.class).last().click();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user