diff --git a/CMakeLists.txt b/CMakeLists.txt index 7652aa56c2..41abb94fb0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,8 @@ if (CMAKE_COMPILER_IS_GNUCXX) -Wmissing-include-dirs \ -Woverloaded-virtual \ -Wredundant-decls \ - -Wsign-promo") # TODO - add back -Wshadow once fixed inside inja, lots of compiler warnings + -Wshadow \ + -Wsign-promo") else () set(CMAKE_CXX_FLAGS "/EHsc") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:10000000") @@ -51,6 +52,8 @@ endif() # includes relative to top level jak-project folder include_directories(./) +include_directories(SYSTEM third-party/inja) + # build spdlog as a shared library to improve compile times # adding this as a SYSTEM include suppresses all the terrible warnings in spdlog include_directories(SYSTEM third-party/spdlog/include) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 43c0cdc3ee..7cc6b5be20 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -18,6 +18,7 @@ add_executable(goalc-test test_emitter_integer_math.cpp test_common_util.cpp test_deftype.cpp + test_pretty_print.cpp ${GOALC_TEST_FRAMEWORK_SOURCES} ${GOALC_TEST_CASES}) diff --git a/test/goalc/framework/test_runner.cpp b/test/goalc/framework/test_runner.cpp index a9cc841cff..c428a03ca1 100644 --- a/test/goalc/framework/test_runner.cpp +++ b/test/goalc/framework/test_runner.cpp @@ -4,7 +4,7 @@ #include #include "gtest/gtest.h" -#include "third-party/inja.hpp" +#include "inja.hpp" #include "third-party/json.hpp" #include "game/runtime.h" diff --git a/test/goalc/framework/test_runner.h b/test/goalc/framework/test_runner.h index 4a47954b7e..d332d15cc0 100644 --- a/test/goalc/framework/test_runner.h +++ b/test/goalc/framework/test_runner.h @@ -3,7 +3,7 @@ #include #include -#include "third-party/inja.hpp" +#include "inja.hpp" #include "goalc/compiler/Compiler.h" namespace GoalTest { diff --git a/test/goalc/test_arithmetic.cpp b/test/goalc/test_arithmetic.cpp index fe4e89ef63..35a2c6f46e 100644 --- a/test/goalc/test_arithmetic.cpp +++ b/test/goalc/test_arithmetic.cpp @@ -8,7 +8,7 @@ #include "goalc/listener/Listener.h" #include "goalc/compiler/Compiler.h" -#include "third-party/inja.hpp" +#include "inja.hpp" #include "third-party/json.hpp" #include @@ -31,6 +31,10 @@ // See - // https://github.com/google/googletest/blob/master/googletest/docs/advanced.md#value-parameterized-tests struct IntegerParam { + // Each integer test has a signed value, and can be represented as hex or an integral + s64 val; + bool hex; + // An index is needed to be explicitly set because I couldn't find a way to pull the test-index // number from google's API // TODO - if you can find a way, please improve! @@ -38,11 +42,8 @@ struct IntegerParam { // Why? - since you may choose to generate random values, it's nice for them to be stored after // the tests complete. Some tests may be complex as well int index; - // Each integer test has a signed value, and can be represented as hex or an integral - s64 val; - bool hex; - IntegerParam(s64 val, bool hex = false, int index = 0) : val(val), hex(hex), index(index) {} + IntegerParam(s64 _val, bool _hex = false, int _index = 0) : val(_val), hex(_hex), index(_index) {} // This is used to generate the value that is passed into the template engine // and injected into the file of lisp code. @@ -81,26 +82,35 @@ std::vector genIntegerTests(int numTests, std::mt19937 rng(dev()); std::uniform_int_distribution dist6(0, UINT32_MAX); int testCases = 3; - for (int i = 0; i < numTests; i++) { - switch (i % testCases) { + int test_index = 0; + for (; test_index < numTests; test_index++) { + switch (test_index % testCases) { case 0: - tests.push_back(IntegerParam(dist6(rng), false, i)); + tests.push_back(IntegerParam(dist6(rng), false, test_index)); break; case 1: - tests.push_back(IntegerParam((s64)dist6(rng) * -1, false, i)); + tests.push_back(IntegerParam((s64)dist6(rng) * -1, false, test_index)); break; case 2: - tests.push_back(IntegerParam(dist6(rng), true, i)); + tests.push_back(IntegerParam(dist6(rng), true, test_index)); break; } } - for (int i = 0; i < additionalTests.size(); i++) { + for (int i = 0; i < int(additionalTests.size()); i++) { IntegerParam test = additionalTests.at(i); test.index = i + numTests - 1; tests.push_back(test); } + for (auto x : + {s64(UINT32_MAX), s64(INT32_MIN), s64(INT32_MAX), s64(0), s64(INT64_MAX), s64(INT64_MIN)}) { + for (auto y : {-1, 0, 1}) { + s64 value = x + s64(y); + tests.emplace_back(value, false, test_index++); + } + } + return tests; } diff --git a/test/goalc/test_collections.cpp b/test/goalc/test_collections.cpp index dc38d944a1..0f6efea2c8 100644 --- a/test/goalc/test_collections.cpp +++ b/test/goalc/test_collections.cpp @@ -6,7 +6,7 @@ #include "goalc/listener/Listener.h" #include "goalc/compiler/Compiler.h" -#include "third-party/inja.hpp" +#include "inja.hpp" #include "third-party/json.hpp" #include diff --git a/test/goalc/test_control_statements.cpp b/test/goalc/test_control_statements.cpp index 2f920a3f0d..0aec9acd05 100644 --- a/test/goalc/test_control_statements.cpp +++ b/test/goalc/test_control_statements.cpp @@ -6,7 +6,7 @@ #include "goalc/listener/Listener.h" #include "goalc/compiler/Compiler.h" -#include "third-party/inja.hpp" +#include "inja.hpp" #include "third-party/json.hpp" #include diff --git a/test/goalc/test_float.cpp b/test/goalc/test_float.cpp index 24819176ac..7f235dbebf 100644 --- a/test/goalc/test_float.cpp +++ b/test/goalc/test_float.cpp @@ -6,7 +6,7 @@ #include "goalc/listener/Listener.h" #include "goalc/compiler/Compiler.h" -#include "third-party/inja.hpp" +#include "inja.hpp" #include "third-party/json.hpp" #include diff --git a/test/goalc/test_functions.cpp b/test/goalc/test_functions.cpp index eddee8a985..7dac93e890 100644 --- a/test/goalc/test_functions.cpp +++ b/test/goalc/test_functions.cpp @@ -6,7 +6,7 @@ #include "goalc/listener/Listener.h" #include "goalc/compiler/Compiler.h" -#include "third-party/inja.hpp" +#include "inja.hpp" #include "third-party/json.hpp" #include diff --git a/test/goalc/test_library.cpp b/test/goalc/test_library.cpp index 045e881b10..960c9102f0 100644 --- a/test/goalc/test_library.cpp +++ b/test/goalc/test_library.cpp @@ -6,7 +6,7 @@ #include "goalc/listener/Listener.h" #include "goalc/compiler/Compiler.h" -#include "third-party/inja.hpp" +#include "inja.hpp" #include "third-party/json.hpp" #include diff --git a/test/goalc/test_logic.cpp b/test/goalc/test_logic.cpp index 326a2f97d1..20c5243138 100644 --- a/test/goalc/test_logic.cpp +++ b/test/goalc/test_logic.cpp @@ -6,7 +6,7 @@ #include "goalc/listener/Listener.h" #include "goalc/compiler/Compiler.h" -#include "third-party/inja.hpp" +#include "inja.hpp" #include "third-party/json.hpp" #include diff --git a/test/goalc/test_loop_recur.cpp b/test/goalc/test_loop_recur.cpp index feac01ba33..171b76217a 100644 --- a/test/goalc/test_loop_recur.cpp +++ b/test/goalc/test_loop_recur.cpp @@ -6,7 +6,7 @@ #include "goalc/listener/Listener.h" #include "goalc/compiler/Compiler.h" -#include "third-party/inja.hpp" +#include "inja.hpp" #include "third-party/json.hpp" #include diff --git a/test/goalc/test_macros.cpp b/test/goalc/test_macros.cpp index d92ca35f2b..fc1fb6f593 100644 --- a/test/goalc/test_macros.cpp +++ b/test/goalc/test_macros.cpp @@ -6,7 +6,7 @@ #include "goalc/listener/Listener.h" #include "goalc/compiler/Compiler.h" -#include "third-party/inja.hpp" +#include "inja.hpp" #include "third-party/json.hpp" #include diff --git a/test/goalc/test_methods.cpp b/test/goalc/test_methods.cpp index d3026475f0..a80659d9e6 100644 --- a/test/goalc/test_methods.cpp +++ b/test/goalc/test_methods.cpp @@ -6,7 +6,7 @@ #include "goalc/listener/Listener.h" #include "goalc/compiler/Compiler.h" -#include "third-party/inja.hpp" +#include "inja.hpp" #include "third-party/json.hpp" #include diff --git a/test/goalc/test_pointers.cpp b/test/goalc/test_pointers.cpp index 98b75a85f5..7205b89363 100644 --- a/test/goalc/test_pointers.cpp +++ b/test/goalc/test_pointers.cpp @@ -6,7 +6,7 @@ #include "goalc/listener/Listener.h" #include "goalc/compiler/Compiler.h" -#include "third-party/inja.hpp" +#include "inja.hpp" #include "third-party/json.hpp" #include diff --git a/test/goalc/test_strings.cpp b/test/goalc/test_strings.cpp index 9db9fcab5c..41a5e061b9 100644 --- a/test/goalc/test_strings.cpp +++ b/test/goalc/test_strings.cpp @@ -6,7 +6,7 @@ #include "goalc/listener/Listener.h" #include "goalc/compiler/Compiler.h" -#include "third-party/inja.hpp" +#include "inja.hpp" #include "third-party/json.hpp" #include diff --git a/test/goalc/test_symbols.cpp b/test/goalc/test_symbols.cpp index 196121881d..af78515962 100644 --- a/test/goalc/test_symbols.cpp +++ b/test/goalc/test_symbols.cpp @@ -6,7 +6,7 @@ #include "goalc/listener/Listener.h" #include "goalc/compiler/Compiler.h" -#include "third-party/inja.hpp" +#include "inja.hpp" #include "third-party/json.hpp" #include diff --git a/test/goalc/test_variables.cpp b/test/goalc/test_variables.cpp index 6caa32202a..075cbdf558 100644 --- a/test/goalc/test_variables.cpp +++ b/test/goalc/test_variables.cpp @@ -6,7 +6,7 @@ #include "goalc/listener/Listener.h" #include "goalc/compiler/Compiler.h" -#include "third-party/inja.hpp" +#include "inja.hpp" #include "third-party/json.hpp" #include diff --git a/test/goalc/test_with_game.cpp b/test/goalc/test_with_game.cpp index 94dc1ad3b2..ba5a19f9c0 100644 --- a/test/goalc/test_with_game.cpp +++ b/test/goalc/test_with_game.cpp @@ -6,7 +6,7 @@ #include "goalc/listener/Listener.h" #include "goalc/compiler/Compiler.h" -#include "third-party/inja.hpp" +#include "inja.hpp" #include "third-party/json.hpp" #include "common/util/FileUtil.h" #include diff --git a/third-party/inja.hpp b/third-party/inja/inja.hpp similarity index 100% rename from third-party/inja.hpp rename to third-party/inja/inja.hpp