mirror of
https://gitlab.kit.edu/uskyk/typicalc.git
synced 2024-11-08 10:20:41 +00:00
parent
7d4c724338
commit
2715179182
@ -224,6 +224,9 @@ public class LambdaParser {
|
||||
return new Result<>(null, error.get().expectedInput(ExpectedInput.TERM));
|
||||
}
|
||||
Result<LambdaTerm, ParseError> term = parseTerm(false);
|
||||
if (term.isError()) {
|
||||
return term; // return error early
|
||||
}
|
||||
error = expect(TokenType.RIGHT_PARENTHESIS);
|
||||
if (error.isEmpty()) {
|
||||
return term;
|
||||
|
@ -7,6 +7,7 @@ import nl.jqno.equalsverifier.EqualsVerifier;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
class LambdaParserTest {
|
||||
private static final VarTerm X = new VarTerm("x");
|
||||
@ -202,6 +203,15 @@ class LambdaParserTest {
|
||||
assertEquals(3, error.getPosition());
|
||||
}
|
||||
|
||||
@Test
|
||||
void errorCase1() {
|
||||
LambdaParser parser = new LambdaParser("(λx.x)(λ");
|
||||
ParseError error = parser.parse().unwrapError();
|
||||
assertEquals(TokenType.EOF, error.getCause().get().getType());
|
||||
assertEquals(1, error.getExpected().get().size());
|
||||
assertTrue(error.getExpected().get().contains(TokenType.VARIABLE));
|
||||
}
|
||||
|
||||
@Test
|
||||
void equality() {
|
||||
EqualsVerifier.forClass(Token.class).usingGetClass().verify();
|
||||
|
Loading…
Reference in New Issue
Block a user