Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up some warnings and add some extra integer tests #71

Merged
merged 1 commit into from
Oct 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})

Expand Down
2 changes: 1 addition & 1 deletion test/goalc/framework/test_runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <string>

#include "gtest/gtest.h"
#include "third-party/inja.hpp"
#include "inja.hpp"
#include "third-party/json.hpp"

#include "game/runtime.h"
Expand Down
2 changes: 1 addition & 1 deletion test/goalc/framework/test_runner.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <string>
#include <vector>

#include "third-party/inja.hpp"
#include "inja.hpp"
#include "goalc/compiler/Compiler.h"

namespace GoalTest {
Expand Down
32 changes: 21 additions & 11 deletions test/goalc/test_arithmetic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <test/goalc/framework/test_runner.h>
Expand All @@ -31,18 +31,19 @@
// 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!
// But this is needed so we can uniquely save the template files, especially if they error out
// 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.
Expand Down Expand Up @@ -81,26 +82,35 @@ std::vector<IntegerParam> genIntegerTests(int numTests,
std::mt19937 rng(dev());
std::uniform_int_distribution<std::mt19937::result_type> 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;
}

Expand Down
2 changes: 1 addition & 1 deletion test/goalc/test_collections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <test/goalc/framework/test_runner.h>

Expand Down
2 changes: 1 addition & 1 deletion test/goalc/test_control_statements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <test/goalc/framework/test_runner.h>

Expand Down
2 changes: 1 addition & 1 deletion test/goalc/test_float.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <test/goalc/framework/test_runner.h>

Expand Down
2 changes: 1 addition & 1 deletion test/goalc/test_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <test/goalc/framework/test_runner.h>

Expand Down
2 changes: 1 addition & 1 deletion test/goalc/test_library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <test/goalc/framework/test_runner.h>

Expand Down
2 changes: 1 addition & 1 deletion test/goalc/test_logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <test/goalc/framework/test_runner.h>

Expand Down
2 changes: 1 addition & 1 deletion test/goalc/test_loop_recur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <test/goalc/framework/test_runner.h>

Expand Down
2 changes: 1 addition & 1 deletion test/goalc/test_macros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <test/goalc/framework/test_runner.h>

Expand Down
2 changes: 1 addition & 1 deletion test/goalc/test_methods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <test/goalc/framework/test_runner.h>

Expand Down
2 changes: 1 addition & 1 deletion test/goalc/test_pointers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <test/goalc/framework/test_runner.h>

Expand Down
2 changes: 1 addition & 1 deletion test/goalc/test_strings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <test/goalc/framework/test_runner.h>

Expand Down
2 changes: 1 addition & 1 deletion test/goalc/test_symbols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <test/goalc/framework/test_runner.h>

Expand Down
2 changes: 1 addition & 1 deletion test/goalc/test_variables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <test/goalc/framework/test_runner.h>

Expand Down
2 changes: 1 addition & 1 deletion test/goalc/test_with_game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <test/goalc/framework/test_runner.h>
Expand Down
File renamed without changes.