mirror of
https://github.com/open-goal/jak-project
synced 2026-07-07 06:05:15 -04:00
Fix remaining failing tests
This commit is contained in:
+3
-4
@@ -15,10 +15,9 @@ add_executable(goalc-test
|
||||
test_emitter_xmm32.cpp
|
||||
test_emitter_integer_math.cpp
|
||||
test_common_util.cpp
|
||||
test_compiler_and_runtime.cpp
|
||||
test_deftype.cpp
|
||||
${GOALC_TEST_FRAMEWORK_SOURCES}
|
||||
${GOALC_TEST_CASES})
|
||||
${GOALC_TEST_FRAMEWORK_SOURCES}
|
||||
${GOALC_TEST_CASES})
|
||||
|
||||
enable_testing()
|
||||
|
||||
@@ -26,7 +25,7 @@ IF (WIN32)
|
||||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
||||
|
||||
# TODO - split out these declarations for platform specific includes
|
||||
target_link_libraries(goalc-test cross_sockets listener mman goos common_util runtime compiler type_system gtest)
|
||||
target_link_libraries(goalc-test cross_sockets goos common_util listener runtime compiler type_system gtest mman)
|
||||
ELSE()
|
||||
target_link_libraries(goalc-test cross_sockets goos common_util listener runtime compiler type_system gtest)
|
||||
ENDIF()
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
set(GOALC_TEST_CASES
|
||||
"goalc/test_arithmetic.cpp"
|
||||
"goalc/test_compiler.cpp"
|
||||
"goalc/test_control_statements.cpp"
|
||||
"goalc/test_collections.cpp"
|
||||
"goalc/test_float.cpp"
|
||||
@@ -15,7 +16,7 @@ set(GOALC_TEST_CASES
|
||||
"goalc/test_strings.cpp"
|
||||
"goalc/test_symbols.cpp"
|
||||
"goalc/test_variables.cpp"
|
||||
# TODO - Failing! "goalc/test_with_game.cpp"
|
||||
"goalc/test_with_game.cpp"
|
||||
)
|
||||
|
||||
set(GOALC_TEST_FRAMEWORK_SOURCES
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "game/runtime.h"
|
||||
#include "goalc/listener/Listener.h"
|
||||
#include "goalc/compiler/Compiler.h"
|
||||
|
||||
TEST(CompilerAndRuntime, ConstructCompiler) {
|
||||
Compiler compiler;
|
||||
}
|
||||
@@ -77,3 +77,42 @@ TEST_F(FunctionTests, Anonymous) {
|
||||
runner.run_static_test(env, testCategory, "declare-inline.static.gc", {"32\n"});
|
||||
runner.run_static_test(env, testCategory, "lambda-1.static.gc", {"2\n"});
|
||||
}
|
||||
|
||||
TEST_F(FunctionTests, InlineIsInline) {
|
||||
auto code = compiler.get_goos().reader.read_from_file(
|
||||
{"test/goalc/source_templates/functions/declare-inline.static.gc"});
|
||||
auto compiled = compiler.compile_object_file("test-code", code, true);
|
||||
EXPECT_EQ(compiled->functions().size(), 2);
|
||||
auto& ir = compiled->top_level_function().code();
|
||||
bool got_mult = false;
|
||||
for (auto& x : ir) {
|
||||
EXPECT_EQ(dynamic_cast<IR_FunctionCall*>(x.get()), nullptr);
|
||||
auto as_im = dynamic_cast<IR_IntegerMath*>(x.get());
|
||||
if (as_im) {
|
||||
EXPECT_EQ(as_im->get_kind(), IntegerMathKind::IMUL_32);
|
||||
got_mult = true;
|
||||
}
|
||||
}
|
||||
EXPECT_TRUE(got_mult);
|
||||
}
|
||||
|
||||
TEST_F(FunctionTests, AllowInline) {
|
||||
auto code = compiler.get_goos().reader.read_from_file(
|
||||
{"test/goalc/source_templates/functions/inline-call.static.gc"});
|
||||
auto compiled = compiler.compile_object_file("test-code", code, true);
|
||||
EXPECT_EQ(compiled->functions().size(), 2);
|
||||
auto& ir = compiled->top_level_function().code();
|
||||
int got_mult = 0;
|
||||
int got_call = 0;
|
||||
for (auto& x : ir) {
|
||||
if (dynamic_cast<IR_FunctionCall*>(x.get())) {
|
||||
got_call++;
|
||||
}
|
||||
auto as_im = dynamic_cast<IR_IntegerMath*>(x.get());
|
||||
if (as_im && as_im->get_kind() == IntegerMathKind::IMUL_32) {
|
||||
got_mult++;
|
||||
}
|
||||
}
|
||||
EXPECT_EQ(got_mult, 1);
|
||||
EXPECT_EQ(got_call, 1);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,13 @@ struct WithGameParam {
|
||||
class WithGameTests : public testing::TestWithParam<WithGameParam> {
|
||||
public:
|
||||
static void SetUpTestSuite() {
|
||||
try {
|
||||
compiler.run_test_no_load("test/goalc/source_templates/with_game/test-build-game.gc");
|
||||
} catch (std::exception& e) {
|
||||
fprintf(stderr, "caught exception %s\n", e.what());
|
||||
EXPECT_TRUE(false);
|
||||
}
|
||||
|
||||
runtime_thread = std::thread((GoalTest::runtime_with_kernel));
|
||||
runner.c = &compiler;
|
||||
}
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "game/runtime.h"
|
||||
#include "goalc/listener/Listener.h"
|
||||
#include "goalc/compiler/Compiler.h"
|
||||
|
||||
TEST(CompilerAndRuntime, ConstructCompiler) {
|
||||
Compiler compiler;
|
||||
}
|
||||
|
||||
// TODO -move these into another file?
|
||||
TEST(CompilerAndRuntime, InlineIsInline) {
|
||||
Compiler compiler;
|
||||
auto code =
|
||||
compiler.get_goos().reader.read_from_file({"goal_src", "test", "test-declare-inline.gc"});
|
||||
auto compiled = compiler.compile_object_file("test-code", code, true);
|
||||
EXPECT_EQ(compiled->functions().size(), 2);
|
||||
auto& ir = compiled->top_level_function().code();
|
||||
bool got_mult = false;
|
||||
for (auto& x : ir) {
|
||||
EXPECT_EQ(dynamic_cast<IR_FunctionCall*>(x.get()), nullptr);
|
||||
auto as_im = dynamic_cast<IR_IntegerMath*>(x.get());
|
||||
if (as_im) {
|
||||
EXPECT_EQ(as_im->get_kind(), IntegerMathKind::IMUL_32);
|
||||
got_mult = true;
|
||||
}
|
||||
}
|
||||
EXPECT_TRUE(got_mult);
|
||||
}
|
||||
|
||||
TEST(CompilerAndRuntime, AllowInline) {
|
||||
Compiler compiler;
|
||||
auto code =
|
||||
compiler.get_goos().reader.read_from_file({"goal_src", "test", "test-inline-call.gc"});
|
||||
auto compiled = compiler.compile_object_file("test-code", code, true);
|
||||
EXPECT_EQ(compiled->functions().size(), 2);
|
||||
auto& ir = compiled->top_level_function().code();
|
||||
int got_mult = 0;
|
||||
int got_call = 0;
|
||||
for (auto& x : ir) {
|
||||
if (dynamic_cast<IR_FunctionCall*>(x.get())) {
|
||||
got_call++;
|
||||
}
|
||||
auto as_im = dynamic_cast<IR_IntegerMath*>(x.get());
|
||||
if (as_im && as_im->get_kind() == IntegerMathKind::IMUL_32) {
|
||||
got_mult++;
|
||||
}
|
||||
}
|
||||
EXPECT_EQ(got_mult, 1);
|
||||
EXPECT_EQ(got_call, 1);
|
||||
}
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <common\util\FileUtil.h>
|
||||
#include "common/util/FileUtil.h"
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
Reference in New Issue
Block a user