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 7d2ad60
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ jobs:
- name: Configure Project
uses: threeal/cmake-action@v1.3.0
with:
c-compiler: gcc
cxx-compiler: g++
c-compiler: clang
cxx-compiler: clang++
cxx-flags: "--std=c++17"

- name: Build Project
run: cmake --build build

- name: Run-Tests
run: ./build/test/run_crux_test
run: ./build/test/run_crux_test
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 7d2ad60

Please sign in to comment.