CI: test coverage

And a complicated parser test
This commit is contained in:
Arne Keller 2021-01-28 10:31:58 +01:00
parent cd3612b60b
commit c5a3cce7bf
5 changed files with 83 additions and 2 deletions

View File

@ -2,3 +2,7 @@ build:
script:
- mvn -Dmaven.repo.local=/tmp/m2/repository -Duser.home=/tmp checkstyle:check
- mvn -Dmaven.repo.local=/tmp/m2/repository -Duser.home=/tmp test
- mvn -Dmaven.repo.local=/tmp/m2/repository -Duser.home=/tmp cobertura:cobertura
artifacts:
reports:
cobertura: target/site/cobertura/coverage.xml

27
pom.xml
View File

@ -154,6 +154,17 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
<configuration>
<check/>
<formats>
<format>xml</format>
</formats>
</configuration>
</plugin>
<plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
@ -255,4 +266,20 @@
</profile>
</profiles>
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
<configuration>
<check/>
<formats>
<format>xml</format>
</formats>
</configuration>
</plugin>
</plugins>
</reporting>
</project>

View File

@ -6,11 +6,14 @@ public enum ParseError {
* the lambda term didn't meet the specified syntax
*/
UNEXPECTED_TOKEN,
/**
* some tokens were remaining after parsing a full lambda term
*/
TOO_MANY_TOKENS,
/**
* the String contained a character not allowed in that place
* the string contained a character not allowed in that context
*/
UNEXPECTED_CHARACTER
}

View File

@ -2,6 +2,8 @@ package edu.kit.typicalc.model.term;
import edu.kit.typicalc.model.type.NamedType;
import java.util.Objects;
/**
* Representation of a constant boolean lambda term: either false or true.
*/
@ -30,4 +32,21 @@ public class BooleanTerm extends ConstTerm {
public String toString() {
return Boolean.toString(value);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
BooleanTerm that = (BooleanTerm) o;
return value == that.value;
}
@Override
public int hashCode() {
return Objects.hash(value);
}
}

View File

@ -4,6 +4,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import edu.kit.typicalc.model.term.AbsTerm;
import edu.kit.typicalc.model.term.AppTerm;
import edu.kit.typicalc.model.term.BooleanTerm;
import edu.kit.typicalc.model.term.ConstTerm;
import edu.kit.typicalc.model.term.IntegerTerm;
import edu.kit.typicalc.model.term.LambdaTerm;
@ -49,4 +50,31 @@ class LambdaParserTest {
)
));
}
@Test
void complicatedTerm() {
LambdaParser parser = new LambdaParser("(λx.λy.x y 5)(λz.z)(true)");
assertEquals(parser.parse().unwrap(),
new AppTerm(
new AppTerm(
new AbsTerm(
new VarTerm("x"),
new AbsTerm(
new VarTerm("y"),
new AppTerm(
new AppTerm(
new VarTerm("x"),
new VarTerm("y")
),
new IntegerTerm(5)
)
)
),
new AbsTerm(
new VarTerm("z"),
new VarTerm("z")
)
),
new BooleanTerm(true)
));
}
}