Lines Matching refs:state
69 is_available(lutok::state& state, const char* symbol) in is_available() argument
71 luaL_loadstring(raw(state), (std::string("return ") + symbol).c_str()); in is_available()
72 const bool ok = (lua_pcall(raw(state), 0, 1, 0) == 0 && in is_available()
73 !lua_isnil(raw(state), -1)); in is_available()
74 lua_pop(raw(state), 1); in is_available()
88 check_modules(lutok::state& state, const std::string& expected) in check_modules() argument
92 ATF_REQUIRE(!((expected == "base") ^ (is_available(state, "assert")))); in check_modules()
94 (is_available(state, "string.byte")))); in check_modules()
96 (is_available(state, "table.concat")))); in check_modules()
111 lutok::state state = lutok::state_c_gate::connect(raw_state); in c_get_upvalues() local
112 const int i1 = lua_tointeger(raw_state, state.upvalue_index(1)); in c_get_upvalues()
113 const int i2 = lua_tointeger(raw_state, state.upvalue_index(2)); in c_get_upvalues()
129 cxx_multiply_closure(lutok::state& state) in cxx_multiply_closure() argument
131 const int f1 = lua_tointeger(raw(state), lua_upvalueindex(1)); in cxx_multiply_closure()
132 const int f2 = lua_tointeger(raw(state), -1); in cxx_multiply_closure()
133 lua_pushinteger(raw(state), f1 * f2); in cxx_multiply_closure()
154 cxx_divide(lutok::state& state) in cxx_divide() argument
156 const int dividend = state.to_integer(-2); in cxx_divide()
157 const int divisor = state.to_integer(-1); in cxx_divide()
162 state.push_integer(dividend / divisor); in cxx_divide()
163 state.push_integer(dividend % divisor); in cxx_divide()
179 raise_long_error(lutok::state& state) in raise_long_error() argument
181 const int length = state.to_integer(); in raise_long_error()
192 lutok::state state; in ATF_TEST_CASE_BODY() local
193 state.close(); in ATF_TEST_CASE_BODY()
202 lutok::state state; in ATF_TEST_CASE_BODY() local
203 ATF_REQUIRE(luaL_dostring(raw(state), "test_variable = 3") == 0); in ATF_TEST_CASE_BODY()
204 state.get_global("test_variable"); in ATF_TEST_CASE_BODY()
205 ATF_REQUIRE(lua_isnumber(raw(state), -1)); in ATF_TEST_CASE_BODY()
206 lua_pop(raw(state), 1); in ATF_TEST_CASE_BODY()
213 lutok::state state; in ATF_TEST_CASE_BODY() local
214 state.get_global("test_variable"); in ATF_TEST_CASE_BODY()
215 ATF_REQUIRE(lua_isnil(raw(state), -1)); in ATF_TEST_CASE_BODY()
216 lua_pop(raw(state), 1); in ATF_TEST_CASE_BODY()
223 lutok::state state; in ATF_TEST_CASE_BODY() local
224 ATF_REQUIRE(luaL_dostring(raw(state), "global_variable = 'hello'") == 0); in ATF_TEST_CASE_BODY()
225 state.get_global_table(); in ATF_TEST_CASE_BODY()
226 lua_pushstring(raw(state), "global_variable"); in ATF_TEST_CASE_BODY()
227 lua_gettable(raw(state), -2); in ATF_TEST_CASE_BODY()
228 ATF_REQUIRE(lua_isstring(raw(state), -1)); in ATF_TEST_CASE_BODY()
229 ATF_REQUIRE(std::strcmp("hello", lua_tostring(raw(state), -1)) == 0); in ATF_TEST_CASE_BODY()
230 lua_pop(raw(state), 2); in ATF_TEST_CASE_BODY()
237 lutok::state state; in ATF_TEST_CASE_BODY() local
238 luaL_openlibs(raw(state)); in ATF_TEST_CASE_BODY()
239 ATF_REQUIRE(luaL_dostring(raw(state), "meta = { foo = 567 }; " in ATF_TEST_CASE_BODY()
241 lua_getglobal(raw(state), "t"); in ATF_TEST_CASE_BODY()
242 ATF_REQUIRE(state.get_metafield(-1, "foo")); in ATF_TEST_CASE_BODY()
243 ATF_REQUIRE(lua_isnumber(raw(state), -1)); in ATF_TEST_CASE_BODY()
244 ATF_REQUIRE_EQ(567, lua_tointeger(raw(state), -1)); in ATF_TEST_CASE_BODY()
245 lua_pop(raw(state), 2); in ATF_TEST_CASE_BODY()
252 lutok::state state; in ATF_TEST_CASE_BODY() local
253 luaL_openlibs(raw(state)); in ATF_TEST_CASE_BODY()
254 ATF_REQUIRE(luaL_dostring(raw(state), "meta = { foo = 567 }; " in ATF_TEST_CASE_BODY()
256 lua_getglobal(raw(state), "t"); in ATF_TEST_CASE_BODY()
257 ATF_REQUIRE(!state.get_metafield(-1, "bar")); in ATF_TEST_CASE_BODY()
258 lua_pop(raw(state), 1); in ATF_TEST_CASE_BODY()
265 lutok::state state; in ATF_TEST_CASE_BODY() local
266 luaL_openlibs(raw(state)); in ATF_TEST_CASE_BODY()
267 ATF_REQUIRE(luaL_dostring(raw(state), "meta = { foo = 567 }; " in ATF_TEST_CASE_BODY()
269 lua_getglobal(raw(state), "t"); in ATF_TEST_CASE_BODY()
270 ATF_REQUIRE(state.get_metatable()); in ATF_TEST_CASE_BODY()
271 ATF_REQUIRE(lua_istable(raw(state), -1)); in ATF_TEST_CASE_BODY()
272 lua_pushstring(raw(state), "foo"); in ATF_TEST_CASE_BODY()
273 lua_gettable(raw(state), -2); in ATF_TEST_CASE_BODY()
274 ATF_REQUIRE(lua_isnumber(raw(state), -1)); in ATF_TEST_CASE_BODY()
275 ATF_REQUIRE_EQ(567, lua_tointeger(raw(state), -1)); in ATF_TEST_CASE_BODY()
276 lua_pop(raw(state), 3); in ATF_TEST_CASE_BODY()
283 lutok::state state; in ATF_TEST_CASE_BODY() local
284 luaL_openlibs(raw(state)); in ATF_TEST_CASE_BODY()
285 ATF_REQUIRE(luaL_dostring(raw(state), "meta = { foo = 567 }; " in ATF_TEST_CASE_BODY()
287 lua_getglobal(raw(state), "t"); in ATF_TEST_CASE_BODY()
288 lua_pushinteger(raw(state), 5555); in ATF_TEST_CASE_BODY()
289 ATF_REQUIRE(state.get_metatable(-2)); in ATF_TEST_CASE_BODY()
290 ATF_REQUIRE(lua_istable(raw(state), -1)); in ATF_TEST_CASE_BODY()
291 lua_pushstring(raw(state), "foo"); in ATF_TEST_CASE_BODY()
292 lua_gettable(raw(state), -2); in ATF_TEST_CASE_BODY()
293 ATF_REQUIRE(lua_isnumber(raw(state), -1)); in ATF_TEST_CASE_BODY()
294 ATF_REQUIRE_EQ(567, lua_tointeger(raw(state), -1)); in ATF_TEST_CASE_BODY()
295 lua_pop(raw(state), 4); in ATF_TEST_CASE_BODY()
302 lutok::state state; in ATF_TEST_CASE_BODY() local
303 ATF_REQUIRE(luaL_dostring(raw(state), "t = {}") == 0); in ATF_TEST_CASE_BODY()
304 lua_getglobal(raw(state), "t"); in ATF_TEST_CASE_BODY()
305 ATF_REQUIRE(!state.get_metatable(-1)); in ATF_TEST_CASE_BODY()
306 lua_pop(raw(state), 1); in ATF_TEST_CASE_BODY()
313 lutok::state state; in ATF_TEST_CASE_BODY() local
314 ATF_REQUIRE(luaL_dostring(raw(state), "t = { a = 1, bar = 234 }") == 0); in ATF_TEST_CASE_BODY()
315 lua_getglobal(raw(state), "t"); in ATF_TEST_CASE_BODY()
316 lua_pushstring(raw(state), "bar"); in ATF_TEST_CASE_BODY()
317 state.get_table(); in ATF_TEST_CASE_BODY()
318 ATF_REQUIRE(lua_isnumber(raw(state), -1)); in ATF_TEST_CASE_BODY()
319 ATF_REQUIRE_EQ(234, lua_tointeger(raw(state), -1)); in ATF_TEST_CASE_BODY()
320 lua_pop(raw(state), 2); in ATF_TEST_CASE_BODY()
327 lutok::state state; in ATF_TEST_CASE_BODY() local
328 lua_pushnil(raw(state)); in ATF_TEST_CASE_BODY()
329 lua_pushinteger(raw(state), 1); in ATF_TEST_CASE_BODY()
330 REQUIRE_API_ERROR("lua_gettable", state.get_table()); in ATF_TEST_CASE_BODY()
331 ATF_REQUIRE_EQ(2, lua_gettop(raw(state))); in ATF_TEST_CASE_BODY()
332 lua_pop(raw(state), 2); in ATF_TEST_CASE_BODY()
339 lutok::state state; in ATF_TEST_CASE_BODY() local
340 ATF_REQUIRE(luaL_dostring(raw(state), in ATF_TEST_CASE_BODY()
342 lua_getglobal(raw(state), "the_table"); in ATF_TEST_CASE_BODY()
343 lua_pushstring(raw(state), "baz"); in ATF_TEST_CASE_BODY()
344 state.get_table(); in ATF_TEST_CASE_BODY()
345 ATF_REQUIRE(lua_isnil(raw(state), -1)); in ATF_TEST_CASE_BODY()
346 lua_pop(raw(state), 2); in ATF_TEST_CASE_BODY()
353 lutok::state state; in ATF_TEST_CASE_BODY() local
354 ATF_REQUIRE_EQ(0, state.get_top()); in ATF_TEST_CASE_BODY()
355 lua_pushinteger(raw(state), 3); in ATF_TEST_CASE_BODY()
356 ATF_REQUIRE_EQ(1, state.get_top()); in ATF_TEST_CASE_BODY()
357 lua_pushinteger(raw(state), 3); in ATF_TEST_CASE_BODY()
358 ATF_REQUIRE_EQ(2, state.get_top()); in ATF_TEST_CASE_BODY()
359 lua_pop(raw(state), 2); in ATF_TEST_CASE_BODY()
366 lutok::state state; in ATF_TEST_CASE_BODY() local
367 lua_pushinteger(raw(state), 1); in ATF_TEST_CASE_BODY()
368 lua_pushinteger(raw(state), 2); in ATF_TEST_CASE_BODY()
369 lua_pushinteger(raw(state), 3); in ATF_TEST_CASE_BODY()
370 lua_pushinteger(raw(state), 4); in ATF_TEST_CASE_BODY()
371 state.insert(-3); in ATF_TEST_CASE_BODY()
372 ATF_REQUIRE_EQ(3, lua_tointeger(raw(state), -1)); in ATF_TEST_CASE_BODY()
373 ATF_REQUIRE_EQ(2, lua_tointeger(raw(state), -2)); in ATF_TEST_CASE_BODY()
374 ATF_REQUIRE_EQ(4, lua_tointeger(raw(state), -3)); in ATF_TEST_CASE_BODY()
375 ATF_REQUIRE_EQ(1, lua_tointeger(raw(state), -4)); in ATF_TEST_CASE_BODY()
376 lua_pop(raw(state), 4); in ATF_TEST_CASE_BODY()
383 lutok::state state; in ATF_TEST_CASE_BODY() local
384 ATF_REQUIRE(!state.is_boolean()); in ATF_TEST_CASE_BODY()
391 lutok::state state; in ATF_TEST_CASE_BODY() local
392 lua_pushnil(raw(state)); in ATF_TEST_CASE_BODY()
393 ATF_REQUIRE(!state.is_boolean()); in ATF_TEST_CASE_BODY()
394 lua_pushboolean(raw(state), 1); in ATF_TEST_CASE_BODY()
395 ATF_REQUIRE(state.is_boolean()); in ATF_TEST_CASE_BODY()
396 lua_pop(raw(state), 2); in ATF_TEST_CASE_BODY()
403 lutok::state state; in ATF_TEST_CASE_BODY() local
404 lua_pushboolean(raw(state), 1); in ATF_TEST_CASE_BODY()
405 ATF_REQUIRE(state.is_boolean(-1)); in ATF_TEST_CASE_BODY()
406 lua_pushinteger(raw(state), 5); in ATF_TEST_CASE_BODY()
407 ATF_REQUIRE(!state.is_boolean(-1)); in ATF_TEST_CASE_BODY()
408 ATF_REQUIRE(state.is_boolean(-2)); in ATF_TEST_CASE_BODY()
409 lua_pop(raw(state), 2); in ATF_TEST_CASE_BODY()
416 lutok::state state; in ATF_TEST_CASE_BODY() local
417 ATF_REQUIRE(!state.is_function()); in ATF_TEST_CASE_BODY()
424 lutok::state state; in ATF_TEST_CASE_BODY() local
425 luaL_dostring(raw(state), "function my_func(a, b) return a + b; end"); in ATF_TEST_CASE_BODY()
427 lua_pushnil(raw(state)); in ATF_TEST_CASE_BODY()
428 ATF_REQUIRE(!state.is_function()); in ATF_TEST_CASE_BODY()
429 lua_getglobal(raw(state), "my_func"); in ATF_TEST_CASE_BODY()
430 ATF_REQUIRE(state.is_function()); in ATF_TEST_CASE_BODY()
431 lua_pop(raw(state), 2); in ATF_TEST_CASE_BODY()
438 lutok::state state; in ATF_TEST_CASE_BODY() local
439 luaL_dostring(raw(state), "function my_func(a, b) return a + b; end"); in ATF_TEST_CASE_BODY()
441 lua_getglobal(raw(state), "my_func"); in ATF_TEST_CASE_BODY()
442 ATF_REQUIRE(state.is_function(-1)); in ATF_TEST_CASE_BODY()
443 lua_pushinteger(raw(state), 5); in ATF_TEST_CASE_BODY()
444 ATF_REQUIRE(!state.is_function(-1)); in ATF_TEST_CASE_BODY()
445 ATF_REQUIRE(state.is_function(-2)); in ATF_TEST_CASE_BODY()
446 lua_pop(raw(state), 2); in ATF_TEST_CASE_BODY()
453 lutok::state state; in ATF_TEST_CASE_BODY() local
454 ATF_REQUIRE(state.is_nil()); in ATF_TEST_CASE_BODY()
461 lutok::state state; in ATF_TEST_CASE_BODY() local
462 lua_pushnil(raw(state)); in ATF_TEST_CASE_BODY()
463 ATF_REQUIRE(state.is_nil()); in ATF_TEST_CASE_BODY()
464 lua_pushinteger(raw(state), 5); in ATF_TEST_CASE_BODY()
465 ATF_REQUIRE(!state.is_nil()); in ATF_TEST_CASE_BODY()
466 lua_pop(raw(state), 2); in ATF_TEST_CASE_BODY()
473 lutok::state state; in ATF_TEST_CASE_BODY() local
474 lua_pushnil(raw(state)); in ATF_TEST_CASE_BODY()
475 ATF_REQUIRE(state.is_nil(-1)); in ATF_TEST_CASE_BODY()
476 lua_pushinteger(raw(state), 5); in ATF_TEST_CASE_BODY()
477 ATF_REQUIRE(!state.is_nil(-1)); in ATF_TEST_CASE_BODY()
478 ATF_REQUIRE(state.is_nil(-2)); in ATF_TEST_CASE_BODY()
479 lua_pop(raw(state), 2); in ATF_TEST_CASE_BODY()
486 lutok::state state; in ATF_TEST_CASE_BODY() local
487 ATF_REQUIRE(!state.is_number()); in ATF_TEST_CASE_BODY()
494 lutok::state state; in ATF_TEST_CASE_BODY() local
495 lua_pushnil(raw(state)); in ATF_TEST_CASE_BODY()
496 ATF_REQUIRE(!state.is_number()); in ATF_TEST_CASE_BODY()
497 lua_pushinteger(raw(state), 5); in ATF_TEST_CASE_BODY()
498 ATF_REQUIRE(state.is_number()); in ATF_TEST_CASE_BODY()
499 lua_pop(raw(state), 2); in ATF_TEST_CASE_BODY()
506 lutok::state state; in ATF_TEST_CASE_BODY() local
507 lua_pushnil(raw(state)); in ATF_TEST_CASE_BODY()
508 ATF_REQUIRE(!state.is_number(-1)); in ATF_TEST_CASE_BODY()
509 lua_pushinteger(raw(state), 5); in ATF_TEST_CASE_BODY()
510 ATF_REQUIRE(state.is_number(-1)); in ATF_TEST_CASE_BODY()
511 ATF_REQUIRE(!state.is_number(-2)); in ATF_TEST_CASE_BODY()
512 lua_pop(raw(state), 2); in ATF_TEST_CASE_BODY()
519 lutok::state state; in ATF_TEST_CASE_BODY() local
520 ATF_REQUIRE(!state.is_string()); in ATF_TEST_CASE_BODY()
527 lutok::state state; in ATF_TEST_CASE_BODY() local
528 lua_pushnil(raw(state)); in ATF_TEST_CASE_BODY()
529 ATF_REQUIRE(!state.is_string()); in ATF_TEST_CASE_BODY()
530 lua_pushinteger(raw(state), 3); in ATF_TEST_CASE_BODY()
531 ATF_REQUIRE(state.is_string()); in ATF_TEST_CASE_BODY()
532 lua_pushstring(raw(state), "foo"); in ATF_TEST_CASE_BODY()
533 ATF_REQUIRE(state.is_string()); in ATF_TEST_CASE_BODY()
534 lua_pop(raw(state), 3); in ATF_TEST_CASE_BODY()
541 lutok::state state; in ATF_TEST_CASE_BODY() local
542 lua_pushinteger(raw(state), 3); in ATF_TEST_CASE_BODY()
543 ATF_REQUIRE(state.is_string(-1)); in ATF_TEST_CASE_BODY()
544 lua_pushnil(raw(state)); in ATF_TEST_CASE_BODY()
545 ATF_REQUIRE(!state.is_string(-1)); in ATF_TEST_CASE_BODY()
546 ATF_REQUIRE(state.is_string(-2)); in ATF_TEST_CASE_BODY()
547 lua_pushstring(raw(state), "foo"); in ATF_TEST_CASE_BODY()
548 ATF_REQUIRE(state.is_string(-1)); in ATF_TEST_CASE_BODY()
549 ATF_REQUIRE(!state.is_string(-2)); in ATF_TEST_CASE_BODY()
550 ATF_REQUIRE(state.is_string(-3)); in ATF_TEST_CASE_BODY()
551 lua_pop(raw(state), 3); in ATF_TEST_CASE_BODY()
558 lutok::state state; in ATF_TEST_CASE_BODY() local
559 ATF_REQUIRE(!state.is_table()); in ATF_TEST_CASE_BODY()
566 lutok::state state; in ATF_TEST_CASE_BODY() local
567 luaL_dostring(raw(state), "t = {3, 4, 5}"); in ATF_TEST_CASE_BODY()
569 lua_pushstring(raw(state), "foo"); in ATF_TEST_CASE_BODY()
570 ATF_REQUIRE(!state.is_table()); in ATF_TEST_CASE_BODY()
571 lua_getglobal(raw(state), "t"); in ATF_TEST_CASE_BODY()
572 ATF_REQUIRE(state.is_table()); in ATF_TEST_CASE_BODY()
573 lua_pop(raw(state), 2); in ATF_TEST_CASE_BODY()
580 lutok::state state; in ATF_TEST_CASE_BODY() local
581 luaL_dostring(raw(state), "t = {3, 4, 5}"); in ATF_TEST_CASE_BODY()
583 lua_pushstring(raw(state), "foo"); in ATF_TEST_CASE_BODY()
584 ATF_REQUIRE(!state.is_table(-1)); in ATF_TEST_CASE_BODY()
585 lua_getglobal(raw(state), "t"); in ATF_TEST_CASE_BODY()
586 ATF_REQUIRE(state.is_table(-1)); in ATF_TEST_CASE_BODY()
587 ATF_REQUIRE(!state.is_table(-2)); in ATF_TEST_CASE_BODY()
588 lua_pop(raw(state), 2); in ATF_TEST_CASE_BODY()
595 lutok::state state; in ATF_TEST_CASE_BODY() local
596 ATF_REQUIRE(!state.is_userdata()); in ATF_TEST_CASE_BODY()
603 lutok::state state; in ATF_TEST_CASE_BODY() local
605 lua_pushstring(raw(state), "foo"); in ATF_TEST_CASE_BODY()
606 ATF_REQUIRE(!state.is_userdata()); in ATF_TEST_CASE_BODY()
607 lua_newuserdata(raw(state), 1234); in ATF_TEST_CASE_BODY()
608 ATF_REQUIRE(state.is_userdata()); in ATF_TEST_CASE_BODY()
609 lua_pop(raw(state), 2); in ATF_TEST_CASE_BODY()
616 lutok::state state; in ATF_TEST_CASE_BODY() local
618 lua_pushstring(raw(state), "foo"); in ATF_TEST_CASE_BODY()
619 ATF_REQUIRE(!state.is_userdata(-1)); in ATF_TEST_CASE_BODY()
620 lua_newuserdata(raw(state), 543); in ATF_TEST_CASE_BODY()
621 ATF_REQUIRE(state.is_userdata(-1)); in ATF_TEST_CASE_BODY()
622 ATF_REQUIRE(!state.is_userdata(-2)); in ATF_TEST_CASE_BODY()
623 lua_pop(raw(state), 2); in ATF_TEST_CASE_BODY()
634 lutok::state state; in ATF_TEST_CASE_BODY() local
635 state.load_file("test.lua"); in ATF_TEST_CASE_BODY()
636 ATF_REQUIRE(lua_pcall(raw(state), 0, 0, 0) == 0); in ATF_TEST_CASE_BODY()
637 lua_getglobal(raw(state), "in_the_file"); in ATF_TEST_CASE_BODY()
638 ATF_REQUIRE(std::strcmp("oh yes", lua_tostring(raw(state), -1)) == 0); in ATF_TEST_CASE_BODY()
639 lua_pop(raw(state), 1); in ATF_TEST_CASE_BODY()
650 lutok::state state; in ATF_TEST_CASE_BODY() local
651 REQUIRE_API_ERROR("luaL_loadfile", state.load_file("test.lua")); in ATF_TEST_CASE_BODY()
658 lutok::state state; in ATF_TEST_CASE_BODY() local
660 state.load_file("missing.lua")); in ATF_TEST_CASE_BODY()
667 lutok::state state; in ATF_TEST_CASE_BODY() local
668 state.load_string("return 2 + 3"); in ATF_TEST_CASE_BODY()
669 ATF_REQUIRE(lua_pcall(raw(state), 0, 1, 0) == 0); in ATF_TEST_CASE_BODY()
670 ATF_REQUIRE_EQ(5, lua_tointeger(raw(state), -1)); in ATF_TEST_CASE_BODY()
671 lua_pop(raw(state), 1); in ATF_TEST_CASE_BODY()
678 lutok::state state; in ATF_TEST_CASE_BODY() local
679 REQUIRE_API_ERROR("luaL_loadstring", state.load_string("-")); in ATF_TEST_CASE_BODY()
686 lutok::state state; in ATF_TEST_CASE_BODY() local
687 state.new_table(); in ATF_TEST_CASE_BODY()
688 ATF_REQUIRE_EQ(1, lua_gettop(raw(state))); in ATF_TEST_CASE_BODY()
689 ATF_REQUIRE(lua_istable(raw(state), -1)); in ATF_TEST_CASE_BODY()
690 lua_pop(raw(state), 1); in ATF_TEST_CASE_BODY()
697 lutok::state state; in ATF_TEST_CASE_BODY() local
698 int* pointer = state.new_userdata< int >(); in ATF_TEST_CASE_BODY()
700 ATF_REQUIRE_EQ(1, lua_gettop(raw(state))); in ATF_TEST_CASE_BODY()
701 ATF_REQUIRE(lua_isuserdata(raw(state), -1)); in ATF_TEST_CASE_BODY()
702 lua_pop(raw(state), 1); in ATF_TEST_CASE_BODY()
709 lutok::state state; in ATF_TEST_CASE_BODY() local
710 luaL_dostring(raw(state), "t = {}"); in ATF_TEST_CASE_BODY()
712 lua_getglobal(raw(state), "t"); in ATF_TEST_CASE_BODY()
713 lua_pushstring(raw(state), "this is a dummy value"); in ATF_TEST_CASE_BODY()
714 lua_pushnil(raw(state)); in ATF_TEST_CASE_BODY()
715 ATF_REQUIRE(!state.next(-3)); in ATF_TEST_CASE_BODY()
716 lua_pop(raw(state), 2); in ATF_TEST_CASE_BODY()
723 lutok::state state; in ATF_TEST_CASE_BODY() local
724 luaL_dostring(raw(state), "t = {}; t[1] = 100; t[2] = 200"); in ATF_TEST_CASE_BODY()
726 lua_getglobal(raw(state), "t"); in ATF_TEST_CASE_BODY()
727 lua_pushnil(raw(state)); in ATF_TEST_CASE_BODY()
729 ATF_REQUIRE(state.next()); in ATF_TEST_CASE_BODY()
730 ATF_REQUIRE_EQ(3, lua_gettop(raw(state))); in ATF_TEST_CASE_BODY()
731 ATF_REQUIRE(lua_isnumber(raw(state), -2)); in ATF_TEST_CASE_BODY()
732 ATF_REQUIRE_EQ(1, lua_tointeger(raw(state), -2)); in ATF_TEST_CASE_BODY()
733 ATF_REQUIRE(lua_isnumber(raw(state), -1)); in ATF_TEST_CASE_BODY()
734 ATF_REQUIRE_EQ(100, lua_tointeger(raw(state), -1)); in ATF_TEST_CASE_BODY()
735 lua_pop(raw(state), 1); in ATF_TEST_CASE_BODY()
737 ATF_REQUIRE(state.next()); in ATF_TEST_CASE_BODY()
738 ATF_REQUIRE_EQ(3, lua_gettop(raw(state))); in ATF_TEST_CASE_BODY()
739 ATF_REQUIRE(lua_isnumber(raw(state), -2)); in ATF_TEST_CASE_BODY()
740 ATF_REQUIRE_EQ(2, lua_tointeger(raw(state), -2)); in ATF_TEST_CASE_BODY()
741 ATF_REQUIRE(lua_isnumber(raw(state), -1)); in ATF_TEST_CASE_BODY()
742 ATF_REQUIRE_EQ(200, lua_tointeger(raw(state), -1)); in ATF_TEST_CASE_BODY()
743 lua_pop(raw(state), 1); in ATF_TEST_CASE_BODY()
745 ATF_REQUIRE(!state.next()); in ATF_TEST_CASE_BODY()
746 lua_pop(raw(state), 1); in ATF_TEST_CASE_BODY()
753 lutok::state state; in ATF_TEST_CASE_BODY() local
754 check_modules(state, ""); in ATF_TEST_CASE_BODY()
755 state.open_base(); in ATF_TEST_CASE_BODY()
756 check_modules(state, "base"); in ATF_TEST_CASE_BODY()
763 lutok::state state; in ATF_TEST_CASE_BODY() local
764 check_modules(state, ""); in ATF_TEST_CASE_BODY()
765 state.open_string(); in ATF_TEST_CASE_BODY()
766 check_modules(state, "string"); in ATF_TEST_CASE_BODY()
773 lutok::state state; in ATF_TEST_CASE_BODY() local
774 check_modules(state, ""); in ATF_TEST_CASE_BODY()
775 state.open_table(); in ATF_TEST_CASE_BODY()
776 check_modules(state, "table"); in ATF_TEST_CASE_BODY()
783 lutok::state state; in ATF_TEST_CASE_BODY() local
784 luaL_loadstring(raw(state), "function mul(a, b) return a * b; end"); in ATF_TEST_CASE_BODY()
785 state.pcall(0, 0, 0); in ATF_TEST_CASE_BODY()
786 state.get_global_table(); in ATF_TEST_CASE_BODY()
787 lua_pushstring(raw(state), "mul"); in ATF_TEST_CASE_BODY()
788 lua_gettable(raw(state), -2); in ATF_TEST_CASE_BODY()
789 lua_pushinteger(raw(state), 3); in ATF_TEST_CASE_BODY()
790 lua_pushinteger(raw(state), 5); in ATF_TEST_CASE_BODY()
791 state.pcall(2, 1, 0); in ATF_TEST_CASE_BODY()
792 ATF_REQUIRE_EQ(15, lua_tointeger(raw(state), -1)); in ATF_TEST_CASE_BODY()
793 lua_pop(raw(state), 2); in ATF_TEST_CASE_BODY()
800 lutok::state state; in ATF_TEST_CASE_BODY() local
801 lua_pushnil(raw(state)); in ATF_TEST_CASE_BODY()
802 REQUIRE_API_ERROR("lua_pcall", state.pcall(0, 0, 0)); in ATF_TEST_CASE_BODY()
809 lutok::state state; in ATF_TEST_CASE_BODY() local
810 lua_pushinteger(raw(state), 10); in ATF_TEST_CASE_BODY()
811 lua_pushinteger(raw(state), 20); in ATF_TEST_CASE_BODY()
812 lua_pushinteger(raw(state), 30); in ATF_TEST_CASE_BODY()
813 state.pop(1); in ATF_TEST_CASE_BODY()
814 ATF_REQUIRE_EQ(2, lua_gettop(raw(state))); in ATF_TEST_CASE_BODY()
815 ATF_REQUIRE_EQ(20, lua_tointeger(raw(state), -1)); in ATF_TEST_CASE_BODY()
816 lua_pop(raw(state), 2); in ATF_TEST_CASE_BODY()
823 lutok::state state; in ATF_TEST_CASE_BODY() local
824 lua_pushinteger(raw(state), 10); in ATF_TEST_CASE_BODY()
825 lua_pushinteger(raw(state), 20); in ATF_TEST_CASE_BODY()
826 lua_pushinteger(raw(state), 30); in ATF_TEST_CASE_BODY()
827 state.pop(2); in ATF_TEST_CASE_BODY()
828 ATF_REQUIRE_EQ(1, lua_gettop(raw(state))); in ATF_TEST_CASE_BODY()
829 ATF_REQUIRE_EQ(10, lua_tointeger(raw(state), -1)); in ATF_TEST_CASE_BODY()
830 lua_pop(raw(state), 1); in ATF_TEST_CASE_BODY()
837 lutok::state state; in ATF_TEST_CASE_BODY() local
838 state.push_boolean(true); in ATF_TEST_CASE_BODY()
839 ATF_REQUIRE_EQ(1, lua_gettop(raw(state))); in ATF_TEST_CASE_BODY()
840 ATF_REQUIRE(lua_toboolean(raw(state), -1)); in ATF_TEST_CASE_BODY()
841 state.push_boolean(false); in ATF_TEST_CASE_BODY()
842 ATF_REQUIRE_EQ(2, lua_gettop(raw(state))); in ATF_TEST_CASE_BODY()
843 ATF_REQUIRE(!lua_toboolean(raw(state), -1)); in ATF_TEST_CASE_BODY()
844 ATF_REQUIRE(lua_toboolean(raw(state), -2)); in ATF_TEST_CASE_BODY()
845 lua_pop(raw(state), 2); in ATF_TEST_CASE_BODY()
852 lutok::state state; in ATF_TEST_CASE_BODY() local
853 state.push_integer(15); in ATF_TEST_CASE_BODY()
854 state.push_cxx_closure(cxx_multiply_closure, 1); in ATF_TEST_CASE_BODY()
855 lua_setglobal(raw(state), "cxx_multiply_closure"); in ATF_TEST_CASE_BODY()
857 ATF_REQUIRE(luaL_dostring(raw(state), in ATF_TEST_CASE_BODY()
859 ATF_REQUIRE_EQ(150, lua_tointeger(raw(state), -1)); in ATF_TEST_CASE_BODY()
860 lua_pop(raw(state), 1); in ATF_TEST_CASE_BODY()
867 lutok::state state; in ATF_TEST_CASE_BODY() local
868 state.push_cxx_function(cxx_divide); in ATF_TEST_CASE_BODY()
869 lua_setglobal(raw(state), "cxx_divide"); in ATF_TEST_CASE_BODY()
871 ATF_REQUIRE(luaL_dostring(raw(state), "return cxx_divide(17, 3)") == 0); in ATF_TEST_CASE_BODY()
872 ATF_REQUIRE_EQ(5, lua_tointeger(raw(state), -2)); in ATF_TEST_CASE_BODY()
873 ATF_REQUIRE_EQ(2, lua_tointeger(raw(state), -1)); in ATF_TEST_CASE_BODY()
874 lua_pop(raw(state), 2); in ATF_TEST_CASE_BODY()
881 lutok::state state; in ATF_TEST_CASE_BODY() local
882 state.push_cxx_function(cxx_divide); in ATF_TEST_CASE_BODY()
883 lua_setglobal(raw(state), "cxx_divide"); in ATF_TEST_CASE_BODY()
885 ATF_REQUIRE(luaL_dostring(raw(state), "return cxx_divide(15, 0)") != 0); in ATF_TEST_CASE_BODY()
886 ATF_REQUIRE_MATCH("Divisor is 0", lua_tostring(raw(state), -1)); in ATF_TEST_CASE_BODY()
887 lua_pop(raw(state), 1); in ATF_TEST_CASE_BODY()
894 lutok::state state; in ATF_TEST_CASE_BODY() local
895 state.push_cxx_function(cxx_divide); in ATF_TEST_CASE_BODY()
896 lua_setglobal(raw(state), "cxx_divide"); in ATF_TEST_CASE_BODY()
898 ATF_REQUIRE(luaL_dostring(raw(state), "return cxx_divide(-3, -1)") != 0); in ATF_TEST_CASE_BODY()
899 ATF_REQUIRE_MATCH("Unhandled exception", lua_tostring(raw(state), -1)); in ATF_TEST_CASE_BODY()
900 lua_pop(raw(state), 1); in ATF_TEST_CASE_BODY()
907 lutok::state state; in ATF_TEST_CASE_BODY() local
908 state.push_cxx_function(raise_long_error); in ATF_TEST_CASE_BODY()
909 lua_setglobal(raw(state), "fail"); in ATF_TEST_CASE_BODY()
911 ATF_REQUIRE(luaL_dostring(raw(state), "return fail(900)") != 0); in ATF_TEST_CASE_BODY()
912 ATF_REQUIRE_MATCH(std::string(900, 'A'), lua_tostring(raw(state), -1)); in ATF_TEST_CASE_BODY()
913 lua_pop(raw(state), 1); in ATF_TEST_CASE_BODY()
915 ATF_REQUIRE(luaL_dostring(raw(state), "return fail(8192)") != 0); in ATF_TEST_CASE_BODY()
916 ATF_REQUIRE_MATCH(std::string(900, 'A'), lua_tostring(raw(state), -1)); in ATF_TEST_CASE_BODY()
917 lua_pop(raw(state), 1); in ATF_TEST_CASE_BODY()
924 lutok::state state; in ATF_TEST_CASE_BODY() local
925 state.push_integer(12); in ATF_TEST_CASE_BODY()
926 ATF_REQUIRE_EQ(1, lua_gettop(raw(state))); in ATF_TEST_CASE_BODY()
927 ATF_REQUIRE_EQ(12, lua_tointeger(raw(state), -1)); in ATF_TEST_CASE_BODY()
928 state.push_integer(34); in ATF_TEST_CASE_BODY()
929 ATF_REQUIRE_EQ(2, lua_gettop(raw(state))); in ATF_TEST_CASE_BODY()
930 ATF_REQUIRE_EQ(34, lua_tointeger(raw(state), -1)); in ATF_TEST_CASE_BODY()
931 ATF_REQUIRE_EQ(12, lua_tointeger(raw(state), -2)); in ATF_TEST_CASE_BODY()
932 lua_pop(raw(state), 2); in ATF_TEST_CASE_BODY()
939 lutok::state state; in ATF_TEST_CASE_BODY() local
940 state.push_nil(); in ATF_TEST_CASE_BODY()
941 ATF_REQUIRE_EQ(1, lua_gettop(raw(state))); in ATF_TEST_CASE_BODY()
942 ATF_REQUIRE(lua_isnil(raw(state), -1)); in ATF_TEST_CASE_BODY()
943 state.push_integer(34); in ATF_TEST_CASE_BODY()
944 ATF_REQUIRE_EQ(2, lua_gettop(raw(state))); in ATF_TEST_CASE_BODY()
945 ATF_REQUIRE(!lua_isnil(raw(state), -1)); in ATF_TEST_CASE_BODY()
946 ATF_REQUIRE(lua_isnil(raw(state), -2)); in ATF_TEST_CASE_BODY()
947 lua_pop(raw(state), 2); in ATF_TEST_CASE_BODY()
954 lutok::state state; in ATF_TEST_CASE_BODY() local
958 state.push_string(str); in ATF_TEST_CASE_BODY()
959 ATF_REQUIRE_EQ(1, lua_gettop(raw(state))); in ATF_TEST_CASE_BODY()
960 ATF_REQUIRE_EQ(std::string("first"), lua_tostring(raw(state), -1)); in ATF_TEST_CASE_BODY()
962 state.push_string(str); in ATF_TEST_CASE_BODY()
964 ATF_REQUIRE_EQ(2, lua_gettop(raw(state))); in ATF_TEST_CASE_BODY()
965 ATF_REQUIRE_EQ(std::string("second"), lua_tostring(raw(state), -1)); in ATF_TEST_CASE_BODY()
966 ATF_REQUIRE_EQ(std::string("first"), lua_tostring(raw(state), -2)); in ATF_TEST_CASE_BODY()
967 lua_pop(raw(state), 2); in ATF_TEST_CASE_BODY()
974 lutok::state state; in ATF_TEST_CASE_BODY() local
976 lua_pushinteger(raw(state), 10); in ATF_TEST_CASE_BODY()
977 lua_pushinteger(raw(state), 20); in ATF_TEST_CASE_BODY()
978 state.push_value(); in ATF_TEST_CASE_BODY()
979 ATF_REQUIRE_EQ(3, lua_gettop(raw(state))); in ATF_TEST_CASE_BODY()
980 ATF_REQUIRE_EQ(20, lua_tointeger(raw(state), -1)); in ATF_TEST_CASE_BODY()
981 ATF_REQUIRE_EQ(20, lua_tointeger(raw(state), -2)); in ATF_TEST_CASE_BODY()
982 ATF_REQUIRE_EQ(10, lua_tointeger(raw(state), -3)); in ATF_TEST_CASE_BODY()
983 lua_pop(raw(state), 3); in ATF_TEST_CASE_BODY()
990 lutok::state state; in ATF_TEST_CASE_BODY() local
992 lua_pushinteger(raw(state), 10); in ATF_TEST_CASE_BODY()
993 lua_pushinteger(raw(state), 20); in ATF_TEST_CASE_BODY()
994 state.push_value(-2); in ATF_TEST_CASE_BODY()
995 ATF_REQUIRE_EQ(3, lua_gettop(raw(state))); in ATF_TEST_CASE_BODY()
996 ATF_REQUIRE_EQ(10, lua_tointeger(raw(state), -1)); in ATF_TEST_CASE_BODY()
997 ATF_REQUIRE_EQ(20, lua_tointeger(raw(state), -2)); in ATF_TEST_CASE_BODY()
998 ATF_REQUIRE_EQ(10, lua_tointeger(raw(state), -3)); in ATF_TEST_CASE_BODY()
999 lua_pop(raw(state), 3); in ATF_TEST_CASE_BODY()
1006 lutok::state state; in ATF_TEST_CASE_BODY() local
1008 luaL_openlibs(raw(state)); in ATF_TEST_CASE_BODY()
1010 raw(state), "t = {foo=123} ; setmetatable(t, {__index=1})") == 0); in ATF_TEST_CASE_BODY()
1011 lua_getglobal(raw(state), "t"); in ATF_TEST_CASE_BODY()
1012 lua_pushstring(raw(state), "foo"); in ATF_TEST_CASE_BODY()
1013 state.raw_get(); in ATF_TEST_CASE_BODY()
1014 ATF_REQUIRE(lua_isnumber(raw(state), -1)); in ATF_TEST_CASE_BODY()
1015 ATF_REQUIRE_EQ(123, lua_tointeger(raw(state), -1)); in ATF_TEST_CASE_BODY()
1016 lua_pop(raw(state), 2); in ATF_TEST_CASE_BODY()
1023 lutok::state state; in ATF_TEST_CASE_BODY() local
1025 luaL_openlibs(raw(state)); in ATF_TEST_CASE_BODY()
1027 raw(state), "t = {foo=123} ; setmetatable(t, {__index=1})") == 0); in ATF_TEST_CASE_BODY()
1028 lua_getglobal(raw(state), "t"); in ATF_TEST_CASE_BODY()
1029 lua_pushinteger(raw(state), 9876); in ATF_TEST_CASE_BODY()
1030 lua_pushstring(raw(state), "foo"); in ATF_TEST_CASE_BODY()
1031 state.raw_get(-3); in ATF_TEST_CASE_BODY()
1032 ATF_REQUIRE(lua_isnumber(raw(state), -1)); in ATF_TEST_CASE_BODY()
1033 ATF_REQUIRE_EQ(123, lua_tointeger(raw(state), -1)); in ATF_TEST_CASE_BODY()
1034 ATF_REQUIRE_EQ(9876, lua_tointeger(raw(state), -2)); in ATF_TEST_CASE_BODY()
1035 lua_pop(raw(state), 3); in ATF_TEST_CASE_BODY()
1042 lutok::state state; in ATF_TEST_CASE_BODY() local
1044 luaL_openlibs(raw(state)); in ATF_TEST_CASE_BODY()
1046 raw(state), "t = {} ; setmetatable(t, {__newindex=1})") == 0); in ATF_TEST_CASE_BODY()
1047 lua_getglobal(raw(state), "t"); in ATF_TEST_CASE_BODY()
1048 lua_pushstring(raw(state), "foo"); in ATF_TEST_CASE_BODY()
1049 lua_pushinteger(raw(state), 345); in ATF_TEST_CASE_BODY()
1050 state.raw_set(); in ATF_TEST_CASE_BODY()
1051 ATF_REQUIRE(luaL_dostring(raw(state), "return t.foo") == 0); in ATF_TEST_CASE_BODY()
1052 ATF_REQUIRE(lua_isnumber(raw(state), -1)); in ATF_TEST_CASE_BODY()
1053 ATF_REQUIRE_EQ(345, lua_tointeger(raw(state), -1)); in ATF_TEST_CASE_BODY()
1054 lua_pop(raw(state), 2); in ATF_TEST_CASE_BODY()
1061 lutok::state state; in ATF_TEST_CASE_BODY() local
1063 luaL_openlibs(raw(state)); in ATF_TEST_CASE_BODY()
1065 raw(state), "t = {} ; setmetatable(t, {__newindex=1})") == 0); in ATF_TEST_CASE_BODY()
1066 lua_getglobal(raw(state), "t"); in ATF_TEST_CASE_BODY()
1067 lua_pushinteger(raw(state), 876); in ATF_TEST_CASE_BODY()
1068 lua_pushstring(raw(state), "foo"); in ATF_TEST_CASE_BODY()
1069 lua_pushinteger(raw(state), 345); in ATF_TEST_CASE_BODY()
1070 state.raw_set(-4); in ATF_TEST_CASE_BODY()
1071 ATF_REQUIRE(luaL_dostring(raw(state), "return t.foo") == 0); in ATF_TEST_CASE_BODY()
1072 ATF_REQUIRE(lua_isnumber(raw(state), -1)); in ATF_TEST_CASE_BODY()
1073 ATF_REQUIRE_EQ(345, lua_tointeger(raw(state), -1)); in ATF_TEST_CASE_BODY()
1074 ATF_REQUIRE_EQ(876, lua_tointeger(raw(state), -2)); in ATF_TEST_CASE_BODY()
1075 lua_pop(raw(state), 3); in ATF_TEST_CASE_BODY()
1082 lutok::state state; in ATF_TEST_CASE_BODY() local
1083 lua_pushvalue(raw(state), lutok::registry_index); in ATF_TEST_CASE_BODY()
1084 lua_pushstring(raw(state), "custom_variable"); in ATF_TEST_CASE_BODY()
1085 lua_pushstring(raw(state), "custom value"); in ATF_TEST_CASE_BODY()
1086 lua_settable(raw(state), -3); in ATF_TEST_CASE_BODY()
1087 lua_pop(raw(state), 1); in ATF_TEST_CASE_BODY()
1088 ATF_REQUIRE(luaL_dostring(raw(state), in ATF_TEST_CASE_BODY()
1090 ATF_REQUIRE(lua_isboolean(raw(state), -1)); in ATF_TEST_CASE_BODY()
1091 ATF_REQUIRE(lua_toboolean(raw(state), -1)); in ATF_TEST_CASE_BODY()
1092 lua_pop(raw(state), 1); in ATF_TEST_CASE_BODY()
1099 lutok::state state; in ATF_TEST_CASE_BODY() local
1100 lua_pushinteger(raw(state), 3); in ATF_TEST_CASE_BODY()
1101 state.set_global("test_variable"); in ATF_TEST_CASE_BODY()
1102 ATF_REQUIRE(luaL_dostring(raw(state), "return test_variable + 1") == 0); in ATF_TEST_CASE_BODY()
1103 ATF_REQUIRE(lua_isnumber(raw(state), -1)); in ATF_TEST_CASE_BODY()
1104 ATF_REQUIRE_EQ(4, lua_tointeger(raw(state), -1)); in ATF_TEST_CASE_BODY()
1105 lua_pop(raw(state), 1); in ATF_TEST_CASE_BODY()
1112 lutok::state state; in ATF_TEST_CASE_BODY() local
1114 raw(state), in ATF_TEST_CASE_BODY()
1120 lua_getglobal(raw(state), "numbers"); in ATF_TEST_CASE_BODY()
1121 lua_getglobal(raw(state), "mt"); in ATF_TEST_CASE_BODY()
1122 state.set_metatable(); in ATF_TEST_CASE_BODY()
1123 lua_pop(raw(state), 1); in ATF_TEST_CASE_BODY()
1125 ATF_REQUIRE(luaL_dostring(raw(state), "return numbers + 2") == 0); in ATF_TEST_CASE_BODY()
1126 ATF_REQUIRE(lua_isnumber(raw(state), -1)); in ATF_TEST_CASE_BODY()
1127 ATF_REQUIRE_EQ(7, lua_tointeger(raw(state), -1)); in ATF_TEST_CASE_BODY()
1128 lua_pop(raw(state), 1); in ATF_TEST_CASE_BODY()
1135 lutok::state state; in ATF_TEST_CASE_BODY() local
1137 raw(state), in ATF_TEST_CASE_BODY()
1143 lua_getglobal(raw(state), "numbers"); in ATF_TEST_CASE_BODY()
1144 lua_pushinteger(raw(state), 1234); in ATF_TEST_CASE_BODY()
1145 lua_getglobal(raw(state), "mt"); in ATF_TEST_CASE_BODY()
1146 state.set_metatable(-3); in ATF_TEST_CASE_BODY()
1147 lua_pop(raw(state), 2); in ATF_TEST_CASE_BODY()
1149 ATF_REQUIRE(luaL_dostring(raw(state), "return numbers + 2") == 0); in ATF_TEST_CASE_BODY()
1150 ATF_REQUIRE(lua_isnumber(raw(state), -1)); in ATF_TEST_CASE_BODY()
1151 ATF_REQUIRE_EQ(7, lua_tointeger(raw(state), -1)); in ATF_TEST_CASE_BODY()
1152 lua_pop(raw(state), 1); in ATF_TEST_CASE_BODY()
1159 lutok::state state; in ATF_TEST_CASE_BODY() local
1160 ATF_REQUIRE(luaL_dostring(raw(state), "t = { a = 1, bar = 234 }") == 0); in ATF_TEST_CASE_BODY()
1161 lua_getglobal(raw(state), "t"); in ATF_TEST_CASE_BODY()
1163 lua_pushstring(raw(state), "bar"); in ATF_TEST_CASE_BODY()
1164 lua_pushstring(raw(state), "baz"); in ATF_TEST_CASE_BODY()
1165 state.set_table(); in ATF_TEST_CASE_BODY()
1166 ATF_REQUIRE_EQ(1, lua_gettop(raw(state))); in ATF_TEST_CASE_BODY()
1168 lua_pushstring(raw(state), "a"); in ATF_TEST_CASE_BODY()
1169 lua_gettable(raw(state), -2); in ATF_TEST_CASE_BODY()
1170 ATF_REQUIRE(lua_isnumber(raw(state), -1)); in ATF_TEST_CASE_BODY()
1171 ATF_REQUIRE_EQ(1, lua_tointeger(raw(state), -1)); in ATF_TEST_CASE_BODY()
1172 lua_pop(raw(state), 1); in ATF_TEST_CASE_BODY()
1174 lua_pushstring(raw(state), "bar"); in ATF_TEST_CASE_BODY()
1175 lua_gettable(raw(state), -2); in ATF_TEST_CASE_BODY()
1176 ATF_REQUIRE(lua_isstring(raw(state), -1)); in ATF_TEST_CASE_BODY()
1177 ATF_REQUIRE_EQ(std::string("baz"), lua_tostring(raw(state), -1)); in ATF_TEST_CASE_BODY()
1178 lua_pop(raw(state), 1); in ATF_TEST_CASE_BODY()
1180 lua_pop(raw(state), 1); in ATF_TEST_CASE_BODY()
1187 lutok::state state; in ATF_TEST_CASE_BODY() local
1188 lua_pushnil(raw(state)); in ATF_TEST_CASE_BODY()
1189 lua_pushinteger(raw(state), 1); in ATF_TEST_CASE_BODY()
1190 lua_pushinteger(raw(state), 2); in ATF_TEST_CASE_BODY()
1191 REQUIRE_API_ERROR("lua_settable", state.set_table(-3)); in ATF_TEST_CASE_BODY()
1192 lua_pop(raw(state), 3); in ATF_TEST_CASE_BODY()
1199 lutok::state state; in ATF_TEST_CASE_BODY() local
1200 lua_pushboolean(raw(state), 1); in ATF_TEST_CASE_BODY()
1201 ATF_REQUIRE(state.to_boolean()); in ATF_TEST_CASE_BODY()
1202 lua_pushboolean(raw(state), 0); in ATF_TEST_CASE_BODY()
1203 ATF_REQUIRE(!state.to_boolean()); in ATF_TEST_CASE_BODY()
1204 lua_pop(raw(state), 2); in ATF_TEST_CASE_BODY()
1211 lutok::state state; in ATF_TEST_CASE_BODY() local
1212 lua_pushboolean(raw(state), 0); in ATF_TEST_CASE_BODY()
1213 lua_pushboolean(raw(state), 1); in ATF_TEST_CASE_BODY()
1214 ATF_REQUIRE(!state.to_boolean(-2)); in ATF_TEST_CASE_BODY()
1215 ATF_REQUIRE(state.to_boolean(-1)); in ATF_TEST_CASE_BODY()
1216 lua_pop(raw(state), 2); in ATF_TEST_CASE_BODY()
1223 lutok::state state; in ATF_TEST_CASE_BODY() local
1224 lua_pushstring(raw(state), "34"); in ATF_TEST_CASE_BODY()
1225 ATF_REQUIRE_EQ(34, state.to_integer()); in ATF_TEST_CASE_BODY()
1226 lua_pushinteger(raw(state), 12); in ATF_TEST_CASE_BODY()
1227 ATF_REQUIRE_EQ(12, state.to_integer()); in ATF_TEST_CASE_BODY()
1228 lua_pop(raw(state), 2); in ATF_TEST_CASE_BODY()
1235 lutok::state state; in ATF_TEST_CASE_BODY() local
1236 lua_pushinteger(raw(state), 12); in ATF_TEST_CASE_BODY()
1237 lua_pushstring(raw(state), "foobar"); in ATF_TEST_CASE_BODY()
1238 ATF_REQUIRE_EQ(12, state.to_integer(-2)); in ATF_TEST_CASE_BODY()
1239 lua_pop(raw(state), 2); in ATF_TEST_CASE_BODY()
1246 lutok::state state; in ATF_TEST_CASE_BODY() local
1247 lua_pushstring(raw(state), "foobar"); in ATF_TEST_CASE_BODY()
1248 ATF_REQUIRE_EQ("foobar", state.to_string()); in ATF_TEST_CASE_BODY()
1249 lua_pushinteger(raw(state), 12); in ATF_TEST_CASE_BODY()
1250 ATF_REQUIRE_EQ("12", state.to_string()); in ATF_TEST_CASE_BODY()
1251 lua_pop(raw(state), 2); in ATF_TEST_CASE_BODY()
1258 lutok::state state; in ATF_TEST_CASE_BODY() local
1259 lua_pushstring(raw(state), "foobar"); in ATF_TEST_CASE_BODY()
1260 lua_pushinteger(raw(state), 12); in ATF_TEST_CASE_BODY()
1261 ATF_REQUIRE_EQ("foobar", state.to_string(-2)); in ATF_TEST_CASE_BODY()
1262 ATF_REQUIRE_EQ("12", state.to_string(-1)); in ATF_TEST_CASE_BODY()
1263 lua_pop(raw(state), 2); in ATF_TEST_CASE_BODY()
1270 lutok::state state; in ATF_TEST_CASE_BODY() local
1273 lua_newuserdata(raw(state), sizeof(int))); in ATF_TEST_CASE_BODY()
1277 int* pointer = state.to_userdata< int >(); in ATF_TEST_CASE_BODY()
1279 lua_pop(raw(state), 1); in ATF_TEST_CASE_BODY()
1286 lutok::state state; in ATF_TEST_CASE_BODY() local
1289 lua_newuserdata(raw(state), sizeof(int))); in ATF_TEST_CASE_BODY()
1293 lua_pushinteger(raw(state), 3); in ATF_TEST_CASE_BODY()
1294 int* pointer = state.to_userdata< int >(-2); in ATF_TEST_CASE_BODY()
1296 lua_pop(raw(state), 2); in ATF_TEST_CASE_BODY()
1303 lutok::state state; in ATF_TEST_CASE_BODY() local
1304 lua_pushinteger(raw(state), 25); in ATF_TEST_CASE_BODY()
1305 lua_pushinteger(raw(state), 30); in ATF_TEST_CASE_BODY()
1306 lua_pushcclosure(raw(state), c_get_upvalues, 2); in ATF_TEST_CASE_BODY()
1307 lua_setglobal(raw(state), "c_get_upvalues"); in ATF_TEST_CASE_BODY()
1309 ATF_REQUIRE(luaL_dostring(raw(state), in ATF_TEST_CASE_BODY()
1311 ATF_REQUIRE_EQ(25, lua_tointeger(raw(state), -2)); in ATF_TEST_CASE_BODY()
1312 ATF_REQUIRE_EQ(30, lua_tointeger(raw(state), -1)); in ATF_TEST_CASE_BODY()
1313 lua_pop(raw(state), 2); in ATF_TEST_CASE_BODY()