diff options
Diffstat (limited to 'unit_tests/legacy_tests.cpp')
-rw-r--r-- | unit_tests/legacy_tests.cpp | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/unit_tests/legacy_tests.cpp b/unit_tests/legacy_tests.cpp new file mode 100644 index 0000000..2d88190 --- /dev/null +++ b/unit_tests/legacy_tests.cpp | |||
@@ -0,0 +1,79 @@ | |||
1 | #include "_pch.hpp" | ||
2 | #include "shared.h" | ||
3 | |||
4 | #define RUN_LEGACY_TESTS 1 | ||
5 | #if RUN_LEGACY_TESTS | ||
6 | |||
7 | // ################################################################################################# | ||
8 | |||
9 | class LegacyTestRunner : public FileRunner | ||
10 | { | ||
11 | public: | ||
12 | LegacyTestRunner() | ||
13 | { | ||
14 | [[maybe_unused]] std::filesystem::path const _current{ std::filesystem::current_path() }; | ||
15 | std::filesystem::path _path{ R"(.\lanes\tests\)" }; | ||
16 | root = std::filesystem::canonical(_path).generic_string(); | ||
17 | // I need to append that path to the list of locations where modules can be required | ||
18 | // so that the legacy scripts can require"assert" and find assert.lua | ||
19 | std::string _script{"package.path = package.path.."}; | ||
20 | _script += "';"; | ||
21 | _script += root; | ||
22 | _script += "/?.lua'"; | ||
23 | std::ignore = L.doString(_script.c_str()); | ||
24 | } | ||
25 | }; | ||
26 | |||
27 | TEST_P(LegacyTestRunner, LegacyTest) | ||
28 | { | ||
29 | FileRunnerParam const& _param = GetParam(); | ||
30 | switch (_param.test) { | ||
31 | case TestType::AssertNoLuaError: | ||
32 | ASSERT_EQ(L.doFile(root, _param.script), LuaError::OK) << L; | ||
33 | break; | ||
34 | case TestType::AssertNoThrow: | ||
35 | ASSERT_NO_THROW((std::ignore = L.doFile(root, _param.script), L.close())) << L; | ||
36 | break; | ||
37 | case TestType::AssertThrows: | ||
38 | ASSERT_THROW((std::ignore = L.doFile(root, _param.script), L.close()), std::logic_error) << L; | ||
39 | break; | ||
40 | } | ||
41 | } | ||
42 | |||
43 | INSTANTIATE_TEST_CASE_P( | ||
44 | LegacyTests, | ||
45 | LegacyTestRunner, | ||
46 | ::testing::Values( | ||
47 | "appendud" // 0 | ||
48 | , "atexit" // 1 | ||
49 | , "atomic" // 2 | ||
50 | , "basic" // 3 | ||
51 | , "cancel" // 4 | ||
52 | , "cyclic" // 5 | ||
53 | , "deadlock" // 6 | ||
54 | , "errhangtest" // 7 | ||
55 | , "error" // 8 | ||
56 | , "fibonacci" // 9 | ||
57 | , "fifo" // 10 | ||
58 | , "finalizer" // 11 | ||
59 | , "func_is_string" // 12 | ||
60 | , "irayo_closure" // 13 | ||
61 | , "irayo_recursive" // 14 | ||
62 | , "keeper" // 15 | ||
63 | //, "linda_perf" | ||
64 | , LUA54_ONLY("manual_register") // 16: uses lfs module, currently not available for non-5.4 flavors | ||
65 | , "nameof" // 17 | ||
66 | , "objects" // 18 | ||
67 | , "package" // 19 | ||
68 | , "pingpong" // 20 | ||
69 | , "recursive" // 21 | ||
70 | , "require" // 22 | ||
71 | , "rupval" // 23 | ||
72 | , "timer" // 24 | ||
73 | , LUA54_ONLY("tobeclosed") // 25 | ||
74 | , "track_lanes" // 26 | ||
75 | ) | ||
76 | //, [](::testing::TestParamInfo<FileRunnerParam> const& info_) { return info_.param.script.empty() ? "N/A": std::string{ info_.param.script }; } | ||
77 | ); | ||
78 | |||
79 | #endif // RUN_LEGACY_TESTS \ No newline at end of file | ||