Skip to content

Commit

Permalink
update(tests): update interpreter tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Rohith-Raju committed May 17, 2024
1 parent 353300d commit 61b5987
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions test/TestInterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "Scanner.h"
#include "gtest/gtest.h"
#include <Statement.h>
#include <ios>
#include <string>
#include <vector>

Expand Down Expand Up @@ -48,18 +47,15 @@ TEST(InterpreterTest, TestTernaryExpression) {

TEST(InterpreterTest, TestVarStatement) {
std::string test = "var a = 10; print(a);";

Scanner scan(test);

std::vector<Token> token = scan.scanTokens();

Parser parser(token);
std::vector<Statement *> statement = parser.parse();

testing::internal::CaptureStdout();
Interpreter *interpreter = new Interpreter();
interpreter->interpret(statement);
std::string result = testing::internal::GetCapturedStdout();
ASSERT_EQ(result, "10.000000\n");
delete interpreter;
}

Expand All @@ -74,6 +70,7 @@ TEST(InterpreterTest, TestIfStatement) {
interpreter->interpret(statements);
std::string result = testing::internal::GetCapturedStdout();
ASSERT_EQ(result, "equal\n");
delete interpreter;
}

TEST(InterpreterTest, TestIfElseStatement) {
Expand Down

0 comments on commit 61b5987

Please sign in to comment.