@@ -175,6 +175,38 @@ void corresult_to_main2(kaguya::VariadicArgType args)
175175}
176176
177177
178+ int coroutine_exec (kaguya::LuaThread cor)
179+ {
180+ return cor.resume <int >() * 2 ;
181+ }
182+
183+ KAGUYA_TEST_FUNCTION_DEF (coroutine_on_the_coroutine)(kaguya::State& state)
184+ {
185+ TEST_CHECK (state (" cor1 = coroutine.create( function()"
186+ " coroutine.yield(32) "
187+ " coroutine.yield(53) "
188+ " return 2 "
189+ " end)" ));
190+
191+ state[" coroutine_exec" ] = coroutine_exec;
192+
193+ TEST_CHECK (state (" cor2 = coroutine.wrap( function()"
194+ " coroutine.yield(coroutine_exec(cor1)) "
195+ " coroutine.yield(coroutine_exec(cor1)) "
196+ " return 4 "
197+ " end)" ));
198+
199+ kaguya::LuaRef cor = state[" cor2" ];
200+ int r1 = cor ();
201+ int r2 = cor ();
202+ int r3 = cor ();
203+
204+ TEST_EQUAL (r1, 32 *2 );
205+ TEST_EQUAL (r2, 53 *2 );
206+ TEST_EQUAL (r3, 4 );
207+ }
208+
209+
178210KAGUYA_TEST_FUNCTION_DEF (coroutine_stack)(kaguya::State& state)
179211{
180212 state[" corresult_to_main" ] = &corresult_to_main;
@@ -226,7 +258,7 @@ KAGUYA_TEST_FUNCTION_DEF(bind_to_std_function)(kaguya::State& state)
226258}
227259
228260
229- KAGUYA_TEST_FUNCTION_DEF (zero_to_nullpointer )(kaguya::State& state)
261+ KAGUYA_TEST_FUNCTION_DEF (call_error )(kaguya::State& state)
230262{
231263 state.setErrorHandler (ignore_error_fun);
232264
@@ -243,12 +275,28 @@ KAGUYA_TEST_FUNCTION_DEF(zero_to_nullpointer)(kaguya::State& state)
243275 kaguya::LuaFunction nilfn;
244276 nilfn.call <void >();
245277 }
246-
278+ {
279+ last_error_message = " " ;
280+ kaguya::LuaFunction notfn = state.newTable ();
281+ TEST_COMPARE_NE (last_error_message, " " );
282+ notfn.call <void >();
283+ }
247284}
248285
249286
250- KAGUYA_TEST_FUNCTION_DEF (result_range_based_for )(kaguya::State& state)
287+ KAGUYA_TEST_FUNCTION_DEF (function_result_for )(kaguya::State& state)
251288{
289+ {
290+ const kaguya::FunctionResults empty;
291+ TEST_EQUAL (empty.result_size (), 0 );
292+ std::vector<int > res;
293+ for (kaguya::FunctionResults::iterator it = empty.begin (); it != empty.end (); ++it)
294+ {
295+ res.push_back (*it);
296+ }
297+ TEST_EQUAL (res.size (), 0 );
298+ }
299+
252300 state (" fn =function() return 1,2,4,8,16 end" );
253301 {
254302 std::vector<int > res;
0 commit comments