mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 11:26:18 -04:00
660ef41136
* cleanup * clean up file layout
74 lines
2.1 KiB
C++
74 lines
2.1 KiB
C++
#include <thread>
|
|
#include <chrono>
|
|
|
|
#include "gtest/gtest.h"
|
|
#include "game/runtime.h"
|
|
#include "goalc/listener/Listener.h"
|
|
#include "goalc/compiler/Compiler.h"
|
|
|
|
#include "inja.hpp"
|
|
#include "third-party/json.hpp"
|
|
#include <test/goalc/framework/test_runner.h>
|
|
|
|
#include <iostream>
|
|
#include <string>
|
|
#include <cstdio>
|
|
#include <sstream>
|
|
#include <iostream>
|
|
#include <random>
|
|
#include <filesystem>
|
|
|
|
struct ControlStatementParam {
|
|
// TODO - Not Needed Yet
|
|
};
|
|
|
|
class ControlStatementTests : public testing::TestWithParam<ControlStatementParam> {
|
|
public:
|
|
static void SetUpTestSuite() {
|
|
runtime_thread = std::thread((GoalTest::runtime_no_kernel));
|
|
runner.c = &compiler;
|
|
}
|
|
|
|
static void TearDownTestSuite() {
|
|
compiler.shutdown_target();
|
|
runtime_thread.join();
|
|
}
|
|
|
|
void SetUp() {
|
|
GoalTest::createDirIfAbsent(GoalTest::getTemplateDir(testCategory));
|
|
GoalTest::createDirIfAbsent(GoalTest::getGeneratedDir(testCategory));
|
|
}
|
|
|
|
void TearDown() {}
|
|
|
|
static std::thread runtime_thread;
|
|
static Compiler compiler;
|
|
static GoalTest::CompilerTestRunner runner;
|
|
|
|
std::string testCategory = "control-statements";
|
|
inja::Environment env{GoalTest::getTemplateDir(testCategory),
|
|
GoalTest::getGeneratedDir(testCategory)};
|
|
};
|
|
|
|
std::thread ControlStatementTests::runtime_thread;
|
|
Compiler ControlStatementTests::compiler;
|
|
GoalTest::CompilerTestRunner ControlStatementTests::runner;
|
|
|
|
TEST_F(ControlStatementTests, ConditionalCompilation) {
|
|
runner.run_static_test(env, testCategory, "conditional-compilation.static.gc", {"3\n"});
|
|
}
|
|
|
|
TEST_F(ControlStatementTests, Blocks) {
|
|
runner.run_static_test(env, testCategory, "nested-blocks-1.static.gc", {"7\n"});
|
|
runner.run_static_test(env, testCategory, "nested-blocks-2.static.gc", {"8\n"});
|
|
runner.run_static_test(env, testCategory, "nested-blocks-3.static.gc", {"7\n"});
|
|
}
|
|
|
|
TEST_F(ControlStatementTests, GoTo) {
|
|
runner.run_static_test(env, testCategory, "goto.static.gc", {"3\n"});
|
|
}
|
|
|
|
TEST_F(ControlStatementTests, Branch) {
|
|
runner.run_static_test(env, testCategory, "return-value-of-if.static.gc", {"123\n"});
|
|
}
|