diff options
Diffstat (limited to '')
-rw-r--r-- | unit_tests/lane_tests.cpp | 426 |
1 files changed, 220 insertions, 206 deletions
diff --git a/unit_tests/lane_tests.cpp b/unit_tests/lane_tests.cpp index 8b22fcd..7f5f112 100644 --- a/unit_tests/lane_tests.cpp +++ b/unit_tests/lane_tests.cpp | |||
@@ -4,257 +4,271 @@ | |||
4 | // ################################################################################################# | 4 | // ################################################################################################# |
5 | // ################################################################################################# | 5 | // ################################################################################################# |
6 | 6 | ||
7 | class LaneTests : public ::testing::Test | 7 | TEST_CASE("lanes.gen") |
8 | { | 8 | { |
9 | protected: | ||
10 | LuaState S{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ false } }; | 9 | LuaState S{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ false } }; |
10 | S.requireSuccess("lanes = require 'lanes'.configure()"); | ||
11 | 11 | ||
12 | void SetUp() override | 12 | // --------------------------------------------------------------------------------------------- |
13 | { | ||
14 | std::ignore = S.doString("lanes = require 'lanes'.configure()"); | ||
15 | } | ||
16 | }; | ||
17 | |||
18 | // ################################################################################################# | ||
19 | 13 | ||
20 | TEST_F(LaneTests, GeneratorCreation) | 14 | SECTION("argument checks") |
21 | { | 15 | { |
22 | // no parameter is bad | 16 | // no parameter is bad |
23 | EXPECT_NE(S.doString("lanes.gen()"), LuaError::OK); | 17 | S.requireFailure("lanes.gen()"); |
24 | 18 | ||
25 | // minimal generator needs a function | 19 | // minimal generator needs a function |
26 | EXPECT_EQ(S.doString("lanes.gen(function() end)"), LuaError::OK) << S; | 20 | S.requireSuccess("lanes.gen(function() end)"); |
27 | 21 | ||
28 | // acceptable parameters for the generator are strings, tables, nil, followed by the function body | 22 | // acceptable parameters for the generator are strings, tables, nil, followed by the function body |
29 | EXPECT_EQ(S.doString("lanes.gen(nil, function() end)"), LuaError::OK) << S; | 23 | S.requireSuccess("lanes.gen(nil, function() end)"); |
30 | EXPECT_EQ(S.doString("lanes.gen('', function() end)"), LuaError::OK) << S; | 24 | S.requireSuccess("lanes.gen('', function() end)"); |
31 | EXPECT_EQ(S.doString("lanes.gen({}, function() end)"), LuaError::OK) << S; | 25 | S.requireSuccess("lanes.gen({}, function() end)"); |
32 | EXPECT_EQ(S.doString("lanes.gen('', {}, function() end)"), LuaError::OK) << S; | 26 | S.requireSuccess("lanes.gen('', {}, function() end)"); |
33 | EXPECT_EQ(S.doString("lanes.gen({}, '', function() end)"), LuaError::OK) << S; | 27 | S.requireSuccess("lanes.gen({}, '', function() end)"); |
34 | EXPECT_EQ(S.doString("lanes.gen('', '', function() end)"), LuaError::OK) << S; | 28 | S.requireSuccess("lanes.gen('', '', function() end)"); |
35 | EXPECT_EQ(S.doString("lanes.gen({}, {}, function() end)"), LuaError::OK) << S; | 29 | S.requireSuccess("lanes.gen({}, {}, function() end)"); |
36 | 30 | ||
37 | // anything different should fail: booleans, numbers, any userdata | 31 | // anything different should fail: booleans, numbers, any userdata |
38 | EXPECT_NE(S.doString("lanes.gen(false, function() end)"), LuaError::OK); | 32 | S.requireFailure("lanes.gen(false, function() end)"); |
39 | EXPECT_NE(S.doString("lanes.gen(true, function() end)"), LuaError::OK); | 33 | S.requireFailure("lanes.gen(true, function() end)"); |
40 | EXPECT_NE(S.doString("lanes.gen(42, function() end)"), LuaError::OK); | 34 | S.requireFailure("lanes.gen(42, function() end)"); |
41 | EXPECT_NE(S.doString("lanes.gen(io.stdin, function() end)"), LuaError::OK); | 35 | S.requireFailure("lanes.gen(io.stdin, function() end)"); |
42 | EXPECT_NE(S.doString("lanes.gen(lanes.linda(), function() end)"), LuaError::OK); | 36 | S.requireFailure("lanes.gen(lanes.linda(), function() end)"); |
43 | EXPECT_NE(S.doString("lanes.gen(lanes.linda():deep(), function() end)"), LuaError::OK); | 37 | S.requireFailure("lanes.gen(lanes.linda():deep(), function() end)"); |
44 | 38 | ||
45 | // even if parameter types are correct, the function must come last | 39 | // even if parameter types are correct, the function must come last |
46 | EXPECT_NE(S.doString("lanes.gen(function() end, '')"), LuaError::OK); | 40 | S.requireFailure("lanes.gen(function() end, '')"); |
47 | 41 | ||
48 | // the strings should only list "known base libraries", in any order, or "*" | 42 | // the strings should only list "known base libraries", in any order, or "*" |
49 | // if the particular Lua flavor we build for doesn't support them, they raise an error unless postfixed by '?' | 43 | // if the particular Lua flavor we build for doesn't support them, they raise an error unless postfixed by '?' |
50 | EXPECT_EQ(S.doString("lanes.gen('base', function() end)"), LuaError::OK) << S; | 44 | S.requireSuccess("lanes.gen('base', function() end)"); |
51 | 45 | ||
52 | // bit, ffi, jit are LuaJIT-specific | 46 | // bit, ffi, jit are LuaJIT-specific |
53 | #if LUAJIT_FLAVOR() == 0 | 47 | #if LUAJIT_FLAVOR() == 0 |
54 | EXPECT_NE(S.doString("lanes.gen('bit,ffi,jit', function() end)"), LuaError::OK); | 48 | S.requireFailure("lanes.gen('bit,ffi,jit', function() end)"); |
55 | EXPECT_EQ(S.doString("lanes.gen('bit?,ffi?,jit?', function() end)"), LuaError::OK) << S; | 49 | S.requireSuccess("lanes.gen('bit?,ffi?,jit?', function() end)"); |
56 | #endif // LUAJIT_FLAVOR() | 50 | #endif // LUAJIT_FLAVOR() |
57 | 51 | ||
58 | // bit32 library existed only in Lua 5.2, there is still a loader that will raise an error in Lua 5.3 | 52 | // bit32 library existed only in Lua 5.2, there is still a loader that will raise an error in Lua 5.3 |
59 | #if LUA_VERSION_NUM == 502 || LUA_VERSION_NUM == 503 | 53 | #if LUA_VERSION_NUM == 502 || LUA_VERSION_NUM == 503 |
60 | EXPECT_EQ(S.doString("lanes.gen('bit32', function() end)"), LuaError::OK) << S; | 54 | S.requireSuccess("lanes.gen('bit32', function() end)"); |
61 | #else // LUA_VERSION_NUM == 502 || LUA_VERSION_NUM == 503 | 55 | #else // LUA_VERSION_NUM == 502 || LUA_VERSION_NUM == 503 |
62 | EXPECT_NE(S.doString("lanes.gen('bit32', function() end)"), LuaError::OK); | 56 | S.requireFailure("lanes.gen('bit32', function() end)"); |
63 | EXPECT_EQ(S.doString("lanes.gen('bit32?', function() end)"), LuaError::OK) << S; | 57 | S.requireSuccess("lanes.gen('bit32?', function() end)"); |
64 | #endif // LUA_VERSION_NUM == 502 || LUA_VERSION_NUM == 503 | 58 | #endif // LUA_VERSION_NUM == 502 || LUA_VERSION_NUM == 503 |
65 | 59 | ||
66 | // coroutine library appeared with Lua 5.2 | 60 | // coroutine library appeared with Lua 5.2 |
67 | #if LUA_VERSION_NUM == 501 | 61 | #if LUA_VERSION_NUM == 501 |
68 | EXPECT_NE(S.doString("lanes.gen('coroutine', function() end)"), LuaError::OK); | 62 | S.requireFailure("lanes.gen('coroutine', function() end)"); |
69 | EXPECT_EQ(S.doString("lanes.gen('coroutine?', function() end)"), LuaError::OK) << S; | 63 | S.requireSuccess("lanes.gen('coroutine?', function() end)"); |
70 | #endif // LUA_VERSION_NUM == 501 | 64 | #endif // LUA_VERSION_NUM == 501 |
71 | 65 | ||
72 | EXPECT_EQ(S.doString("lanes.gen('debug', function() end)"), LuaError::OK) << S; | 66 | S.requireSuccess("lanes.gen('debug', function() end)"); |
73 | EXPECT_EQ(S.doString("lanes.gen('io', function() end)"), LuaError::OK) << S; | 67 | S.requireSuccess("lanes.gen('io', function() end)"); |
74 | EXPECT_EQ(S.doString("lanes.gen('math', function() end)"), LuaError::OK) << S; | 68 | S.requireSuccess("lanes.gen('math', function() end)"); |
75 | EXPECT_EQ(S.doString("lanes.gen('os', function() end)"), LuaError::OK) << S; | 69 | S.requireSuccess("lanes.gen('os', function() end)"); |
76 | EXPECT_EQ(S.doString("lanes.gen('package', function() end)"), LuaError::OK) << S; | 70 | S.requireSuccess("lanes.gen('package', function() end)"); |
77 | EXPECT_EQ(S.doString("lanes.gen('string', function() end)"), LuaError::OK) << S; | 71 | S.requireSuccess("lanes.gen('string', function() end)"); |
78 | EXPECT_EQ(S.doString("lanes.gen('table', function() end)"), LuaError::OK) << S; | 72 | S.requireSuccess("lanes.gen('table', function() end)"); |
79 | 73 | ||
80 | // utf8 library appeared with Lua 5.3 | 74 | // utf8 library appeared with Lua 5.3 |
81 | #if LUA_VERSION_NUM < 503 | 75 | #if LUA_VERSION_NUM < 503 |
82 | EXPECT_NE(S.doString("lanes.gen('utf8', function() end)"), LuaError::OK); | 76 | S.requireFailure("lanes.gen('utf8', function() end)"); |
83 | EXPECT_EQ(S.doString("lanes.gen('utf8?', function() end)"), LuaError::OK) << S; | 77 | S.requireSuccess("lanes.gen('utf8?', function() end)"); |
84 | #endif // LUA_VERSION_NUM < 503 | 78 | #endif // LUA_VERSION_NUM < 503 |
85 | 79 | ||
86 | EXPECT_EQ(S.doString("lanes.gen('lanes.core', function() end)"), LuaError::OK) << S; | 80 | S.requireSuccess("lanes.gen('lanes.core', function() end)"); |
87 | // "*" repeated or combined with anything else is forbidden | 81 | // "*" repeated or combined with anything else is forbidden |
88 | EXPECT_NE(S.doString("lanes.gen('*', '*', function() end)"), LuaError::OK); | 82 | S.requireFailure("lanes.gen('*', '*', function() end)"); |
89 | EXPECT_NE(S.doString("lanes.gen('base', '*', function() end)"), LuaError::OK); | 83 | S.requireFailure("lanes.gen('base', '*', function() end)"); |
90 | // unknown names are forbidden | 84 | // unknown names are forbidden |
91 | EXPECT_NE(S.doString("lanes.gen('Base', function() end)"), LuaError::OK); | 85 | S.requireFailure("lanes.gen('Base', function() end)"); |
92 | // repeating the same library more than once is forbidden | 86 | // repeating the same library more than once is forbidden |
93 | EXPECT_NE(S.doString("lanes.gen('base,base', function() end)"), LuaError::OK); | 87 | S.requireFailure("lanes.gen('base,base', function() end)"); |
94 | } | 88 | } |
95 | 89 | ||
96 | // ################################################################################################# | 90 | // --------------------------------------------------------------------------------------------- |
97 | 91 | ||
98 | TEST_F(LaneTests, UncooperativeShutdown) | 92 | SECTION("lanes.finally") // TODO: move this section somewhere else, in a dedicated finally TEST_CASE |
99 | { | 93 | { |
100 | // prepare a callback for lanes.finally() | 94 | // prepare a callback for lanes.finally() |
101 | static bool _wasCalled{}; | 95 | static bool _wasCalled{}; |
102 | static bool _allLanesTerminated{}; | 96 | static bool _allLanesTerminated{}; |
103 | auto _finallyCB{ +[](lua_State* const L_) { _wasCalled = true; _allLanesTerminated = lua_toboolean(L_, 1); return 0; } }; | 97 | auto _finallyCB{ +[](lua_State* const L_) { _wasCalled = true; _allLanesTerminated = lua_toboolean(L_, 1); return 0; } }; |
104 | lua_pushcfunction(S, _finallyCB); | 98 | lua_pushcfunction(S, _finallyCB); |
105 | lua_setglobal(S, "finallyCB"); | 99 | lua_setglobal(S, "finallyCB"); |
106 | // start a lane that lasts a long time | 100 | // start a lane that lasts a long time |
107 | std::string_view const _script{ | 101 | std::string_view const _script{ |
108 | " lanes.finally(finallyCB)" | 102 | " lanes.finally(finallyCB)" |
109 | " g = lanes.gen('*'," | 103 | " g = lanes.gen('*'," |
110 | " {name = 'auto'}," | 104 | " {name = 'auto'}," |
111 | " function()" | 105 | " function()" |
112 | " for i = 1,1e37 do end" // no cooperative cancellation checks here! | 106 | " for i = 1,1e37 do end" // no cooperative cancellation checks here! |
113 | " end)" | 107 | " end)" |
114 | " g()" | 108 | " g()" |
115 | }; | 109 | }; |
116 | ASSERT_EQ(S.doString(_script), LuaError::OK) << S; | 110 | S.requireSuccess(_script); |
117 | // close the state before the lane ends. | 111 | // close the state before the lane ends. |
118 | // since we don't wait at all, it is possible that the OS thread for the lane hasn't even started at that point | 112 | // since we don't wait at all, it is possible that the OS thread for the lane hasn't even started at that point |
119 | S.close(); | 113 | S.close(); |
120 | // the finally handler should have been called, and told all lanes are stopped | 114 | // the finally handler should have been called, and told all lanes are stopped |
121 | ASSERT_EQ(_wasCalled, true) << S; | 115 | REQUIRE(_wasCalled); |
122 | ASSERT_EQ(_allLanesTerminated, true) << S; | 116 | REQUIRE(_allLanesTerminated); |
123 | } | 117 | } |
124 | 118 | ||
125 | // ################################################################################################# | 119 | // --------------------------------------------------------------------------------------------- |
126 | 120 | ||
127 | TEST_F(LaneTests, DefaultThreadNameIsUnnamed) | 121 | SECTION("default thread name is '<unnamed>'") |
128 | { | 122 | { |
129 | std::string_view const _script{ | 123 | std::string_view const _script{ |
130 | " g = lanes.gen('*'," | 124 | " g = lanes.gen('*'," |
131 | " function()" | 125 | " function()" |
132 | " return lane_threadname()" | 126 | " return lane_threadname()" |
133 | " end)" | 127 | " end)" |
134 | " h = g()" | 128 | " h = g()" |
135 | " local tn = h[1]" | 129 | " local tn = h[1]" |
136 | " assert(tn == h:get_threadname())" | 130 | " assert(tn == h:get_threadname())" |
137 | " return tn" | 131 | " assert(tn == '<unnamed>')" |
138 | }; | 132 | }; |
139 | ASSERT_EQ(S.doStringAndRet(_script), "<unnamed>") << S; | 133 | S.requireSuccess(_script); |
140 | } | 134 | } |
141 | 135 | ||
142 | // ################################################################################################# | 136 | // --------------------------------------------------------------------------------------------- |
143 | 137 | ||
144 | TEST_F(LaneTests, UserThreadNameFromGenerator) | 138 | SECTION("set thread name from generator settings") |
145 | { | 139 | { |
146 | std::string_view const _script{ | 140 | std::string_view const _script{ |
147 | " g = lanes.gen('*'," | 141 | " g = lanes.gen('*'," |
148 | " { name = 'user name'}," | 142 | " { name = 'user name'}," |
149 | " function()" | 143 | " function()" |
150 | " return lane_threadname()" | 144 | " return lane_threadname()" |
151 | " end)" | 145 | " end)" |
152 | " h = g()" | 146 | " h = g()" |
153 | " local tn = h[1]" | 147 | " local tn = h[1]" |
154 | " assert(tn == h:get_threadname())" | 148 | " assert(tn == h:get_threadname())" |
155 | " return tn" | 149 | " assert(tn == 'user name')" |
156 | }; | 150 | }; |
157 | ASSERT_EQ(S.doStringAndRet(_script), "user name") << S; | 151 | S.requireSuccess(_script); |
158 | } | 152 | } |
159 | 153 | ||
160 | // ################################################################################################# | 154 | // --------------------------------------------------------------------------------------------- |
161 | 155 | ||
162 | TEST_F(LaneTests, UserThreadNameFromInside) | 156 | SECTION("set thread name from lane body") |
163 | { | 157 | { |
164 | std::string_view const _script{ | 158 | std::string_view const _script{ |
165 | " g = lanes.gen('*'," | 159 | " g = lanes.gen('*'," |
166 | " function()" | 160 | " function()" |
167 | " lane_threadname('user name')" | 161 | " lane_threadname('user name')" |
168 | " return true" | 162 | " return true" |
169 | " end)" | 163 | " end)" |
170 | " h = g()" | 164 | " h = g()" |
171 | " h:join()" | 165 | " h:join()" |
172 | " return h:get_threadname()" | 166 | " assert(h:get_threadname() == 'user name')" |
173 | }; | 167 | }; |
174 | ASSERT_EQ(S.doStringAndRet(_script), "user name") << S; | 168 | S.requireSuccess(_script); |
169 | } | ||
175 | } | 170 | } |
176 | 171 | ||
177 | // ################################################################################################# | 172 | // ################################################################################################# |
178 | // ################################################################################################# | 173 | // ################################################################################################# |
179 | 174 | ||
180 | class LaneCancel : public ::testing::Test | 175 | TEST_CASE("lane:cancel") |
181 | { | 176 | { |
182 | protected: | ||
183 | LuaState S{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ true } }; | 177 | LuaState S{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ true } }; |
184 | 178 | ||
185 | void SetUp() override | 179 | // need the timers so that there is a lane running on which we can operate |
180 | S.requireSuccess("timer_lane = require 'lanes'.configure{with_timers = true}.timer_lane"); | ||
181 | // make sure we have the timer lane and its cancel method handy | ||
182 | S.requireSuccess("assert(timer_lane and timer_lane.cancel)"); | ||
183 | // as well as the fixture module | ||
184 | S.requireSuccess("fixture = require 'fixture'"); | ||
185 | |||
186 | // --------------------------------------------------------------------------------------------- | ||
187 | |||
188 | SECTION("cancel operation must be a known string") | ||
186 | { | 189 | { |
187 | // need the timers so that there is a lane running on which we can operate | 190 | // cancel operation must be a known string |
188 | std::ignore = S.doString("timer_lane = require 'lanes'.configure{with_timers = true}.timer_lane"); | 191 | S.requireFailure("timer_lane:cancel('gleh')"); |
192 | S.requireFailure("timer_lane:cancel(function() end)"); | ||
193 | S.requireFailure("timer_lane:cancel({})"); | ||
194 | S.requireFailure("timer_lane:cancel(fixture.newuserdata())"); | ||
195 | S.requireFailure("timer_lane:cancel(fixture.newlightuserdata())"); | ||
189 | } | 196 | } |
190 | }; | ||
191 | 197 | ||
192 | // ################################################################################################# | 198 | // --------------------------------------------------------------------------------------------- |
193 | 199 | ||
194 | TEST_F(LaneCancel, FailsOnBadArguments) | 200 | SECTION("cancel doesn't expect additional non-number/bool arguments after the mode") |
195 | { | 201 | { |
196 | //FAIL() << "Make sure the failures fail the way we expect them"; | 202 | S.requireFailure("timer_lane:cancel('soft', 'gleh')"); |
197 | // make sure we have the timer lane and its cancel method handy | 203 | S.requireFailure("timer_lane:cancel('soft', function() end)"); |
198 | ASSERT_EQ(S.doString("assert(timer_lane and timer_lane.cancel)"), LuaError::OK); | 204 | S.requireFailure("timer_lane:cancel('soft', {})"); |
199 | // as well as the fixture module | 205 | S.requireFailure("timer_lane:cancel('soft', fixture.newuserdata())"); |
200 | ASSERT_EQ(S.doString("fixture = require 'fixture'"), LuaError::OK) << S; | 206 | S.requireFailure("timer_lane:cancel('soft', fixture.newlightuserdata())"); |
201 | 207 | } | |
202 | // cancel operation must be a known string | 208 | |
203 | ASSERT_NE(S.doString("timer_lane:cancel('gleh')"), LuaError::OK); | 209 | // --------------------------------------------------------------------------------------------- |
204 | ASSERT_NE(S.doString("timer_lane:cancel(function() end)"), LuaError::OK); | 210 | |
205 | ASSERT_NE(S.doString("timer_lane:cancel({})"), LuaError::OK); | 211 | SECTION("hook-based cancellation expects a number for the count. IOW, a bool is not valid") |
206 | ASSERT_NE(S.doString("timer_lane:cancel(fixture.newuserdata())"), LuaError::OK); | 212 | { |
207 | ASSERT_NE(S.doString("timer_lane:cancel(fixture.newlightuserdata())"), LuaError::OK); | 213 | S.requireFailure("timer_lane:cancel('call', true)"); |
208 | 214 | S.requireFailure("timer_lane:cancel('ret', true)"); | |
209 | // cancel doesn't expect additional non-number/bool arguments after the mode | 215 | S.requireFailure("timer_lane:cancel('line', true)"); |
210 | ASSERT_NE(S.doString("timer_lane:cancel('soft', 'gleh')"), LuaError::OK); | 216 | S.requireFailure("timer_lane:cancel('count', true)"); |
211 | ASSERT_NE(S.doString("timer_lane:cancel('soft', function() end)"), LuaError::OK); | 217 | S.requireFailure("timer_lane:cancel('all', true)"); |
212 | ASSERT_NE(S.doString("timer_lane:cancel('soft', {})"), LuaError::OK); | 218 | } |
213 | ASSERT_NE(S.doString("timer_lane:cancel('soft', fixture.newuserdata())"), LuaError::OK); | 219 | |
214 | ASSERT_NE(S.doString("timer_lane:cancel('soft', fixture.newlightuserdata())"), LuaError::OK); | 220 | // --------------------------------------------------------------------------------------------- |
215 | 221 | ||
216 | // hook-based cancellation expects a number for the count. IOW, a bool is not valid | 222 | SECTION("non-hook should only have one number after the mode (the timeout), else it means we have a count") |
217 | ASSERT_NE(S.doString("timer_lane:cancel('call', true)"), LuaError::OK); | 223 | { |
218 | ASSERT_NE(S.doString("timer_lane:cancel('ret', true)"), LuaError::OK); | 224 | S.requireFailure("timer_lane:cancel('hard', 10, 10)"); |
219 | ASSERT_NE(S.doString("timer_lane:cancel('line', true)"), LuaError::OK); | 225 | } |
220 | ASSERT_NE(S.doString("timer_lane:cancel('count', true)"), LuaError::OK); | 226 | |
221 | ASSERT_NE(S.doString("timer_lane:cancel('all', true)"), LuaError::OK); | 227 | // --------------------------------------------------------------------------------------------- |
222 | 228 | ||
223 | // non-hook should only have one number after the mode (the timeout), else it means we have a count | 229 | SECTION("extra arguments are not accepted either") |
224 | ASSERT_NE(S.doString("timer_lane:cancel('hard', 10, 10)"), LuaError::OK); | 230 | { |
225 | 231 | S.requireFailure("timer_lane:cancel('hard', 10, true, 10)"); | |
226 | // extra arguments are not accepted either | 232 | S.requireFailure("timer_lane:cancel('call', 10, 10, 10)"); |
227 | ASSERT_NE(S.doString("timer_lane:cancel('hard', 10, true, 10)"), LuaError::OK); | 233 | S.requireFailure("timer_lane:cancel('line', 10, 10, true, 10)"); |
228 | ASSERT_NE(S.doString("timer_lane:cancel('call', 10, 10, 10)"), LuaError::OK); | 234 | } |
229 | ASSERT_NE(S.doString("timer_lane:cancel('line', 10, 10, true, 10)"), LuaError::OK); | 235 | |
230 | 236 | // --------------------------------------------------------------------------------------------- | |
231 | // out-of-range hook count is not valid | 237 | |
232 | ASSERT_NE(S.doString("timer_lane:cancel('call', -1)"), LuaError::OK); | 238 | SECTION("out-of-range hook count is not valid") |
233 | ASSERT_NE(S.doString("timer_lane:cancel('call', 0)"), LuaError::OK); | 239 | { |
234 | 240 | S.requireFailure("timer_lane:cancel('call', -1)"); | |
235 | // out-of-range duration is not valid | 241 | S.requireFailure("timer_lane:cancel('call', 0)"); |
236 | ASSERT_NE(S.doString("timer_lane:cancel('soft', -1)"), LuaError::OK); | 242 | } |
243 | |||
244 | // --------------------------------------------------------------------------------------------- | ||
245 | |||
246 | SECTION("out-of-range duration is not valid") | ||
247 | { | ||
248 | S.requireFailure("timer_lane:cancel('soft', -1)"); | ||
249 | } | ||
237 | } | 250 | } |
238 | 251 | ||
239 | // ################################################################################################# | 252 | // ################################################################################################# |
240 | // ################################################################################################# | 253 | // ################################################################################################# |
241 | 254 | ||
242 | INSTANTIATE_TEST_CASE_P( | 255 | TEST_CASE("lane scripted tests") |
243 | LaneScriptedTests, | 256 | { |
244 | UnitTestRunner, | 257 | auto const& _testParam = GENERATE( |
245 | ::testing::Values( | 258 | FileRunnerParam{ PUC_LUA_ONLY("lane/cooperative_shutdown"), TestType::AssertNoLuaError }, // 0 |
246 | FileRunnerParam{ PUC_LUA_ONLY("lane/cooperative_shutdown"), TestType::AssertNoLuaError }, // 0 | ||
247 | FileRunnerParam{ "lane/uncooperative_shutdown", TestType::AssertThrows }, | 259 | FileRunnerParam{ "lane/uncooperative_shutdown", TestType::AssertThrows }, |
248 | FileRunnerParam{ "lane/tasking_basic", TestType::AssertNoLuaError }, // 2 | 260 | FileRunnerParam{ "lane/tasking_basic", TestType::AssertNoLuaError }, // 2 |
249 | FileRunnerParam{ "lane/tasking_cancelling", TestType::AssertNoLuaError }, // 3 | 261 | FileRunnerParam{ "lane/tasking_cancelling", TestType::AssertNoLuaError }, // 3 |
250 | FileRunnerParam{ "lane/tasking_comms_criss_cross", TestType::AssertNoLuaError }, // 4 | 262 | FileRunnerParam{ "lane/tasking_comms_criss_cross", TestType::AssertNoLuaError }, // 4 |
251 | FileRunnerParam{ "lane/tasking_communications", TestType::AssertNoLuaError }, | 263 | FileRunnerParam{ "lane/tasking_communications", TestType::AssertNoLuaError }, |
252 | FileRunnerParam{ "lane/tasking_error", TestType::AssertNoLuaError }, // 6 | 264 | FileRunnerParam{ "lane/tasking_error", TestType::AssertNoLuaError }, // 6 |
253 | FileRunnerParam{ "lane/tasking_join_test", TestType::AssertNoLuaError }, // 7 | 265 | FileRunnerParam{ "lane/tasking_join_test", TestType::AssertNoLuaError }, // 7 |
254 | FileRunnerParam{ "lane/tasking_send_receive_code", TestType::AssertNoLuaError }, | 266 | FileRunnerParam{ "lane/tasking_send_receive_code", TestType::AssertNoLuaError }, |
255 | FileRunnerParam{ "lane/stdlib_naming", TestType::AssertNoLuaError }, | 267 | FileRunnerParam{ "lane/stdlib_naming", TestType::AssertNoLuaError }, |
256 | FileRunnerParam{ "coro/basics", TestType::AssertNoLuaError }, // 10 | 268 | FileRunnerParam{ "coro/basics", TestType::AssertNoLuaError }, // 10 |
257 | FileRunnerParam{ "coro/error_handling", TestType::AssertNoLuaError } | 269 | FileRunnerParam{ "coro/error_handling", TestType::AssertNoLuaError } |
258 | ) | 270 | ); |
259 | //,[](::testing::TestParamInfo<FileRunnerParam> const& info_) { return std::string{ info_.param.script };} | 271 | |
260 | ); | 272 | FileRunner _runner(R"(.\lanes\unit_tests\scripts)"); |
273 | _runner.performTest(_testParam); | ||
274 | } | ||