Creates base of script class
This commit is contained in:
@@ -198,6 +198,25 @@ TEST_CASE( "Parse simple negation", "[parser]" ) {
|
||||
CHECK(((LiteralIntegerExpression*)operand)->GetValue() == 10);
|
||||
}
|
||||
|
||||
TEST_CASE( "Parse logical negation", "[parser]" ) {
|
||||
vector<IToken*> v {
|
||||
new SimpleToken(TokenKind::NotKeyword,0,0),
|
||||
new SimpleToken(TokenKind::FalseKeyword,0,0),
|
||||
new SimpleToken(TokenKind::EndOfFile,0,0)
|
||||
};
|
||||
Parser parser = Parser(v);
|
||||
auto parsedStatements = parser.Parse() -> GetStatements();
|
||||
REQUIRE(parsedStatements.size() == 1);
|
||||
auto firstStatement = parsedStatements[0];
|
||||
REQUIRE(firstStatement -> GetKind() == ParsedStatementKind::Expression);
|
||||
auto expression = ((ParsedExpressionStatement*)firstStatement)->GetExpression();
|
||||
REQUIRE(expression -> GetKind() == ParsedExpressionKind::Unary);
|
||||
auto unary = ((UnaryExpression*)expression);
|
||||
CHECK(unary -> GetOperatorKind() == UnaryOperatorKind::LogicalNegation);
|
||||
auto operand = unary->GetOperand();
|
||||
REQUIRE(operand->GetKind() == ParsedExpressionKind::LiteralBool);
|
||||
CHECK(((LiteralBoolExpression*)operand)->GetValue() == false);
|
||||
}
|
||||
|
||||
TEST_CASE( "Assert binary precedence", "[parser]" ) {
|
||||
vector<IToken*> v {
|
||||
|
||||
@@ -28,6 +28,10 @@ public:
|
||||
unsigned int GetLength(){
|
||||
return Length;
|
||||
}
|
||||
|
||||
virtual ~IToken(){
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
class SimpleToken : public IToken{
|
||||
|
||||
Reference in New Issue
Block a user