mirror of
https://gitlab.kit.edu/uskyk/typicalc.git
synced 2024-11-08 18:30:42 +00:00
fix lambda parser test
This commit is contained in:
parent
8d6842043d
commit
e0926d87b7
@ -1,19 +1,13 @@
|
|||||||
package edu.kit.typicalc.model.parser;
|
package edu.kit.typicalc.model.parser;
|
||||||
|
|
||||||
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.IntegerTerm;
|
|
||||||
import edu.kit.typicalc.model.term.LambdaTerm;
|
|
||||||
import edu.kit.typicalc.model.term.LetTerm;
|
|
||||||
import edu.kit.typicalc.model.term.VarTerm;
|
|
||||||
import edu.kit.typicalc.model.parser.Token.TokenType;
|
import edu.kit.typicalc.model.parser.Token.TokenType;
|
||||||
|
import edu.kit.typicalc.model.term.*;
|
||||||
import edu.kit.typicalc.util.Result;
|
import edu.kit.typicalc.util.Result;
|
||||||
import nl.jqno.equalsverifier.EqualsVerifier;
|
import nl.jqno.equalsverifier.EqualsVerifier;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
class LambdaParserTest {
|
class LambdaParserTest {
|
||||||
private static final VarTerm X = new VarTerm("x");
|
private static final VarTerm X = new VarTerm("x");
|
||||||
|
|
||||||
@ -22,9 +16,9 @@ class LambdaParserTest {
|
|||||||
LambdaParser parser = new LambdaParser("x");
|
LambdaParser parser = new LambdaParser("x");
|
||||||
Result<LambdaTerm, ParseError> term = parser.parse();
|
Result<LambdaTerm, ParseError> term = parser.parse();
|
||||||
assertEquals(new VarTerm("x"), term.unwrap());
|
assertEquals(new VarTerm("x"), term.unwrap());
|
||||||
parser = new LambdaParser("β1 α1");
|
parser = new LambdaParser("b1 a1");
|
||||||
term = parser.parse();
|
term = parser.parse();
|
||||||
assertEquals(new AppTerm(new VarTerm("β1"), new VarTerm("α1")), term.unwrap());
|
assertEquals(new AppTerm(new VarTerm("b1"), new VarTerm("a1")), term.unwrap());
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
void absTerm() {
|
void absTerm() {
|
||||||
@ -106,6 +100,10 @@ class LambdaParserTest {
|
|||||||
assertEquals(new Token(TokenType.RIGHT_PARENTHESIS, ")", 1), error.getCause());
|
assertEquals(new Token(TokenType.RIGHT_PARENTHESIS, ")", 1), error.getCause());
|
||||||
parser = new LambdaParser("??");
|
parser = new LambdaParser("??");
|
||||||
assertEquals(ParseError.UNEXPECTED_CHARACTER, parser.parse().unwrapError());
|
assertEquals(ParseError.UNEXPECTED_CHARACTER, parser.parse().unwrapError());
|
||||||
|
parser = new LambdaParser("aλ");
|
||||||
|
assertEquals(ParseError.UNEXPECTED_CHARACTER, parser.parse().unwrapError());
|
||||||
|
parser = new LambdaParser("ä");
|
||||||
|
assertEquals(ParseError.UNEXPECTED_CHARACTER, parser.parse().unwrapError());
|
||||||
parser = new LambdaParser("123333333333333");
|
parser = new LambdaParser("123333333333333");
|
||||||
assertEquals(ParseError.UNEXPECTED_CHARACTER, parser.parse().unwrapError());
|
assertEquals(ParseError.UNEXPECTED_CHARACTER, parser.parse().unwrapError());
|
||||||
parser = new LambdaParser("x 123333333333333");
|
parser = new LambdaParser("x 123333333333333");
|
||||||
|
Loading…
Reference in New Issue
Block a user