Skip to content
This repository was archived by the owner on Mar 15, 2025. It is now read-only.

Add tests for dang-lua Convert and State. #64

Draft
wants to merge 157 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
157 commits
Select commit Hold shift + click to select a range
686b3e1
Added basic test structure for dang-lua.
Possseidon Apr 11, 2022
de3058e
Removed Convert nullopt_t specialization.
Possseidon Sep 3, 2021
4cf35c3
Fix ConvertNil using nullptr instead of TNil.
Possseidon Sep 3, 2021
0fe63e4
Added Convert test for void and nil.
Possseidon Sep 3, 2021
ebebf61
Add push typename for Convert<Fail>.
Possseidon Sep 3, 2021
30fb4db
Add tests for Convert<Fail>.
Possseidon Sep 3, 2021
eb9f73f
nil fixup
Possseidon Sep 3, 2021
f9ad824
Added tests for Convert<bool>.
Possseidon Sep 3, 2021
e2b9c47
Use SFINAE for Convert template and added another todo.
Possseidon Sep 4, 2021
1316114
Remove push default value from Convert nil and fail.
Possseidon Sep 4, 2021
1b22fa5
Temporarily disabled test-State.cpp.
Possseidon Sep 4, 2021
a240978
Some big changes to Convert.
Possseidon Sep 4, 2021
a35d5f4
Added enum tests and did some general restructuring.
Possseidon Sep 4, 2021
6dee50f
Add a todo to rename table() to methods().
Possseidon Sep 4, 2021
2b554e3
Fix bug with null property accessor functions.
Possseidon Sep 4, 2021
68e0e6c
Some cleanup in Convert.h.
Possseidon Sep 4, 2021
0decd66
More tests.
Possseidon Sep 4, 2021
68fdbf4
Temporarily disable dmath in CI, until it works again.
Possseidon Sep 4, 2021
98c874a
Improved convert boolean test slightly.
Possseidon Sep 5, 2021
12a93c1
Fixed Convert for numbers.
Possseidon Sep 5, 2021
946917b
Added convert number test.
Possseidon Sep 5, 2021
3887212
Fixed Convert for integers.
Possseidon Sep 5, 2021
2eebf17
Added convert integer tests.
Possseidon Sep 5, 2021
b66634d
Fixed Convert for strings.
Possseidon Sep 5, 2021
229512c
Avoid potential problems with null strings in enum convert.
Possseidon Sep 5, 2021
c1643aa
Add tests for all the different string Convert specializations.
Possseidon Sep 5, 2021
0888fca
Prefer luaL_typeerror over luaL_argerror.
Possseidon Sep 5, 2021
0b510ba
Fix a gcc warning.
Possseidon Sep 5, 2021
2e2274e
Fix naming consistency "C function".
Possseidon Sep 5, 2021
1607be7
Fix Convert for C functions.
Possseidon Sep 5, 2021
383921d
Add C function convert tests.
Possseidon Sep 5, 2021
3bd6239
Improve convert integer/number related error messages.
Possseidon Sep 5, 2021
bdf869b
Simplify is_nil.
Possseidon Sep 5, 2021
79266fd
Fix Convert for std::optional.
Possseidon Sep 5, 2021
b56c735
Add optional convert tests.
Possseidon Sep 5, 2021
02b8d1e
Fix Convert for std::tuple.
Possseidon Sep 6, 2021
eec2334
Have shouldThrow pop the error message from the stack to keep it clean.
Possseidon Sep 6, 2021
d61cd66
Get rid of using namespace literal in optional test.
Possseidon Sep 6, 2021
c36eb5b
Add pair/tuple convert tests.
Possseidon Sep 6, 2021
81cd0e9
Prefer lua_pushliteral over lua_pushstring.
Possseidon Sep 6, 2021
cdfcf21
Fix Convert for std::variant.
Possseidon Sep 6, 2021
3291235
Add variant convert tests.
Possseidon Sep 6, 2021
2e97634
Change maybe_cref to just maybe_const.
Possseidon Sep 9, 2021
529389e
Added two TODOs for tests.
Possseidon Sep 19, 2021
6ccb854
Some cleanup and improvements in Convert.
Possseidon Sep 19, 2021
2a98131
Improved Convert<std::integral>::checkRange.
Possseidon Sep 19, 2021
c6a1efa
Fix naming convention for (now) combined_push_count.
Possseidon Sep 25, 2021
31f65a7
Extract test LuaState and maybe_const into separate headers.
Possseidon Sep 25, 2021
12050ec
Move Lua Allocator into separate header.
Possseidon Sep 25, 2021
6c2b846
Add tests for Lua allocator.
Possseidon Sep 25, 2021
a3ce512
Also move Lua reference into separate header.
Possseidon Sep 25, 2021
31c941f
Add Lua reference tests.
Possseidon Sep 25, 2021
1bcda68
Add missing Reference.h include in State.h.
Possseidon Sep 25, 2021
e662759
Fix LuaState.h.
Possseidon Sep 25, 2021
b77662c
Remove redundant ; to make gcc happy.
Possseidon Sep 25, 2021
2200936
Make template parameter names more explicit in Convert.h.
Possseidon Sep 25, 2021
d7794dc
Turn auto return into (same) void.
Possseidon Sep 25, 2021
1974431
Fix is_optional and is_variant not allowing cv qualified types.
Possseidon Sep 25, 2021
a76055a
Add tags to reference tests.
Possseidon Sep 25, 2021
51c8bf6
Add tags to allocator tests.
Possseidon Sep 25, 2021
19dad0f
Add missing [convert] tag in test.
Possseidon Sep 25, 2021
a4116f6
Replaced maybe_const with maybe_cv.
Possseidon Sep 25, 2021
228b517
Fix use of remove_const instead of remove_cv.
Possseidon Sep 25, 2021
0091a70
Improved Lua index type traits.
Possseidon Sep 25, 2021
62df77d
Make order of registry and upvalue consistent.
Possseidon Sep 25, 2021
2af276f
Fix NTTP naming convention.
Possseidon Sep 25, 2021
d939f6c
Improved Convert usage in State.
Possseidon Sep 25, 2021
f92f32a
Fix SignatureInfo Convert usage and indexOffset function.
Possseidon Sep 25, 2021
f33734b
Make OwnedState constructor explicit.
Possseidon Sep 25, 2021
e739cac
Remove old debug temporary.
Possseidon Sep 25, 2021
3fca823
Removed reference from Convert<State>.
Possseidon Sep 25, 2021
42d8221
Made two functions constexpr.
Possseidon Sep 25, 2021
4ab71db
Rename/remove some template typenames.
Possseidon Sep 25, 2021
1bdd5ff
Enabled test-State.cpp and added type trait tests.
Possseidon Sep 25, 2021
0ea89a5
Fix State::ref().
Possseidon Sep 25, 2021
f3cba5a
Unfriend ScopedStack from State as it's not really necessary.
Possseidon Sep 26, 2021
bf0ba01
Some minor changes to State.
Possseidon Sep 26, 2021
3fe6003
Tests both member and friend style swap for Reference.
Possseidon Sep 26, 2021
4fcfd9b
Add tests that are exclusive to Lua State.
Possseidon Sep 26, 2021
e6c6bb1
Fix type comparison warning.
Possseidon Sep 26, 2021
a1a7563
Make dummyAllocator static.
Possseidon Sep 26, 2021
56adb49
Changed Lua OwnedState constructor.
Possseidon Sep 26, 2021
a646807
Add tests for Lua OwnedState.
Possseidon Sep 26, 2021
2f57246
Renaming and splitting up of Lua State classes.
Possseidon Sep 26, 2021
a0430c9
Update tests for new Lua State class names.
Possseidon Sep 26, 2021
9aa3bc4
Ignore some checks when they are irrelevant.
Possseidon Sep 26, 2021
fdce54a
Fully qualify some names.
Possseidon Sep 26, 2021
a52216f
Fix incomplete type error.
Possseidon Sep 26, 2021
a90711e
Move StateRef and friends above wrap functions.
Possseidon Sep 26, 2021
e54bcb9
Add a bunch of TODOs.
Possseidon Sep 26, 2021
c364ff4
Replace decay_t with more appropriate type conversions.
Possseidon Sep 26, 2021
2956193
Simplified combined_push_count.
Possseidon Sep 26, 2021
3a2ccca
Fix weird msvc bug with constexpr if.
Possseidon Sep 26, 2021
d7653b9
Fix State move-constructor.
Possseidon Sep 26, 2021
8a3bb3f
Fix format and notify debug output.
Possseidon Sep 26, 2021
d038e5d
Rename a test tag.
Possseidon Sep 26, 2021
68d8fcb
Add Lua State move and swap tests.
Possseidon Sep 26, 2021
7a4e8f5
Extract global allocation set into a CheckedAllocator test class.
Possseidon Sep 26, 2021
2b793d7
More changes to Lua State construction.
Possseidon Sep 26, 2021
17f48bd
Update Lua State tests.
Possseidon Sep 26, 2021
ca3b462
Fix some headers and formatting.
Possseidon Sep 26, 2021
dc8272a
Registered Lua type enums with Catch2.
Possseidon Sep 26, 2021
26e8db3
Make CheckedAllocator::alloc private.
Possseidon Sep 26, 2021
39c510f
Added Lua StateBase tests that are related to the state itself.
Possseidon Sep 26, 2021
afad9bb
Improve documentation on StateBase gc methods.
Possseidon Sep 26, 2021
9fcafc5
Some changes to Convert.h.
Possseidon Sep 27, 2021
c9d593a
Updated Convert Reference with new convertible flag.
Possseidon Sep 27, 2021
452931f
Fix up some Convert tests.
Possseidon Sep 27, 2021
5344cca
Made Lua Index operator bool const.
Possseidon Sep 27, 2021
5c318c4
Fix std::size_t which should be int (because Lua uses int).
Possseidon Sep 27, 2021
959057c
Simplified a line in Lua State::arith.
Possseidon Sep 27, 2021
528c129
Fix Lua State::compare with none values.
Possseidon Sep 27, 2021
c2a2dc1
Fix a doc comment.
Possseidon Sep 27, 2021
ed05b1a
Add new convertible flag to Convert<lua_State*> and Convert<StateRef>.
Possseidon Sep 27, 2021
f47ffdd
Fix Lua Convert for Index types.
Possseidon Sep 27, 2021
95d957b
Fixed Lua arith and compare operators.
Possseidon Sep 27, 2021
773b170
Also allow Convert with non-pointer lua_CFunctions.
Possseidon Sep 27, 2021
c94adcc
Fix Lua SignatureInfo relying on implicit StateRef conversion.
Possseidon Sep 27, 2021
4c8388e
Fix dmath by applying the StateRef rename.
Possseidon Sep 27, 2021
e8aad47
Enabled building dmath in CI again.
Possseidon Sep 27, 2021
69205b6
Minor keyword reordering in Convert.h.
Possseidon Sep 28, 2021
9fb4981
Added a TODO to improve SignatureInfo.
Possseidon Sep 28, 2021
8f9c2da
Made some Lua State functions constexpr and static.
Possseidon Sep 28, 2021
6224173
Reorder Lua State Stack Maintenance section.
Possseidon Sep 28, 2021
c913178
Fix comment on Lua State::isInteger.
Possseidon Sep 28, 2021
5cb00db
Fix assert on Lua State::padWithNil to allow padding "nothing".
Possseidon Sep 28, 2021
b005aa1
Add a TODO to make Lua State::maxFuncArg private.
Possseidon Sep 28, 2021
dce2ae8
Implemented a load of Lua StateBase tests.
Possseidon Sep 28, 2021
2a5e9fe
Fix Lua C function test.
Possseidon Sep 28, 2021
5501861
Fix unused parameter warning.
Possseidon Sep 28, 2021
bb28149
Quite big Convert refactoring.
Possseidon Nov 13, 2021
2069ed6
Heavily split up Convert.h and its tests.
Possseidon Feb 2, 2022
54905e0
Fix ClassInfo usage in State::require.
Possseidon Feb 16, 2022
c39b7fc
Add a todo for more customizable instantiation to ClassInfo.
Possseidon Feb 21, 2022
a9a4564
Fix and improve dang-math Lua bindings.
Possseidon Feb 22, 2022
842851a
Remove a testing TEST_CASE that got committed accidentally.
Possseidon Feb 22, 2022
d890f2b
Fix "explicit specialization in non-namespace scope" error.
Possseidon Feb 23, 2022
7074c9c
Fix more gcc warnings.
Possseidon Feb 23, 2022
8bd5036
Always #include the entire Convert.h.
Possseidon Feb 23, 2022
8917864
Add missing convert/Reference.h to Convert.h.
Possseidon Feb 23, 2022
48cb29d
Fix PushUnpackTupleSkip naming and make it and some helpers private.
Possseidon Feb 23, 2022
40eea77
Get rid of push(std::function) with upvalues.
Possseidon Feb 23, 2022
cb335b7
Fix op_arguments_valid using checkable instead of pushable.
Possseidon Feb 23, 2022
3fea2cc
Add tests for pushing tuples with stack indices.
Possseidon Feb 23, 2022
0a6a29e
Add tests for pushing std::function and dlua friends.
Possseidon Feb 23, 2022
bc873f1
Use tl::expected for dlua::Expected.
Possseidon Feb 23, 2022
8039677
Add pushGlobalTable test.
Possseidon Feb 24, 2022
ce8ae30
Fix State::replace first parameter and improve its logic.
Possseidon Feb 24, 2022
928e4f1
Added tests for State::replace.
Possseidon Feb 24, 2022
b88b886
Add tests for State::pop/remove.
Possseidon Feb 24, 2022
20145af
Add Lua error tests.
Possseidon Feb 24, 2022
67b15d2
Built a better abstraction for Lua chunks than LoadInfo.
Possseidon Feb 24, 2022
26b4d4b
Fix test not using new Lua chunk abstraction.
Possseidon Feb 24, 2022
2833b53
Fix missing inline (ODR).
Possseidon Feb 24, 2022
fefadaf
inline -> constexpr
Possseidon Feb 24, 2022
b8c4ebb
Add State::dump function.
Possseidon Feb 24, 2022
4f875a6
Add load and dump tests.
Possseidon Feb 24, 2022
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
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ if(MSVC)
endif()
else()
add_compile_options(-Wall -Wextra -pedantic $<$<BOOL:${DANG_WERROR}>:-Werror>)
add_compile_options(-Wno-missing-braces -Wno-logical-op-parentheses)
if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
add_compile_options(-Wno-missing-braces -Wno-logical-op-parentheses)
else()
add_compile_options(-Wno-parentheses)
endif()
endif()

dang_add_feature_subdirectory(BOX2D dang-box2d)
Expand Down
9 changes: 7 additions & 2 deletions dang-lua/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ dang_check_dependencies(UTILS)
dang_include_finder(FindLua)

dang_find_package(Lua REQUIRED)
dang_find_package(tl-expected CONFIG REQUIRED)

add_library(${PROJECT_NAME} INTERFACE)

Expand All @@ -25,20 +26,24 @@ target_precompile_headers(
<memory>
<numeric>
<optional>
<string>
<string_view>
<string>
<tuple>
<type_traits>
<typeinfo>
<variant>)

target_link_libraries(${PROJECT_NAME} INTERFACE dang-utils lua-cpp)
target_link_libraries(${PROJECT_NAME} INTERFACE dang-utils lua-cpp tl::expected)

target_include_directories(${PROJECT_NAME} INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)

add_subdirectory(stl)

if(BUILD_TESTING)
add_subdirectory(tests)
endif()

install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ TYPE INCLUDE)

install(TARGETS ${PROJECT_NAME} EXPORT dang-lib-targets)
18 changes: 18 additions & 0 deletions dang-lua/include/dang-lua/Allocator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma once

#include "dang-lua/global.h"

namespace dang::lua {

/// @brief Wraps allocation function and optional userdata, which Lua passes to this function.
struct Allocator {
constexpr Allocator(lua_Alloc function, void* userdata = nullptr)
: function(function)
, userdata(userdata)
{}

lua_Alloc function;
void* userdata;
};

} // namespace dang::lua
Loading