Lines Matching refs:state
36 #include "state.ipp"
49 /// \param state The Lua state.
53 hook_add(lutok::state& state)
55 state.push_integer(state.to_integer(-1) + state.to_integer(-2));
66 /// \param state The Lua state.
70 hook_multiply(lutok::state& state)
72 state.push_integer(state.to_integer(-1) * state.to_integer(-2));
83 lutok::state state;
85 lutok::create_module(state, "my_math", members);
87 state.open_base();
88 lutok::do_string(state, "return next(my_math) == nil", 1);
89 ATF_REQUIRE(state.to_boolean());
90 state.pop(1);
97 lutok::state state;
100 lutok::create_module(state, "my_math", members);
102 lutok::do_string(state, "return my_math.add(10, 20)", 1);
103 ATF_REQUIRE_EQ(30, state.to_integer());
104 state.pop(1);
111 lutok::state state;
116 lutok::create_module(state, "my_math", members);
118 lutok::do_string(state, "return my_math.add(10, 20)", 1);
119 ATF_REQUIRE_EQ(30, state.to_integer());
120 lutok::do_string(state, "return my_math.multiply(10, 20)", 1);
121 ATF_REQUIRE_EQ(200, state.to_integer());
122 lutok::do_string(state, "return my_math.add2(20, 30)", 1);
123 ATF_REQUIRE_EQ(50, state.to_integer());
124 state.pop(3);
135 lutok::state state;
136 ATF_REQUIRE_EQ(3, lutok::do_file(state, "test.lua", -1));
137 ATF_REQUIRE_EQ(3, state.get_top());
138 ATF_REQUIRE_EQ(10, state.to_integer(-3));
139 ATF_REQUIRE_EQ(20, state.to_integer(-2));
140 ATF_REQUIRE_EQ(30, state.to_integer(-1));
141 state.pop(3);
152 lutok::state state;
153 ATF_REQUIRE_EQ(0, lutok::do_file(state, "test.lua"));
154 ATF_REQUIRE_EQ(0, state.get_top());
165 lutok::state state;
166 ATF_REQUIRE_EQ(2, lutok::do_file(state, "test.lua", 2));
167 ATF_REQUIRE_EQ(2, state.get_top());
168 ATF_REQUIRE_EQ(10, state.to_integer(-2));
169 ATF_REQUIRE_EQ(20, state.to_integer(-1));
170 state.pop(2);
177 lutok::state state;
178 stack_balance_checker checker(state);
180 lutok::do_file(state, "missing.lua"));
191 lutok::state state;
192 stack_balance_checker checker(state);
194 lutok::do_file(state, "test.lua"));
201 lutok::state state;
202 ATF_REQUIRE_EQ(3, lutok::do_string(state, "return 10, 20, 30", -1));
203 ATF_REQUIRE_EQ(3, state.get_top());
204 ATF_REQUIRE_EQ(10, state.to_integer(-3));
205 ATF_REQUIRE_EQ(20, state.to_integer(-2));
206 ATF_REQUIRE_EQ(30, state.to_integer(-1));
207 state.pop(3);
214 lutok::state state;
215 ATF_REQUIRE_EQ(0, lutok::do_string(state, "return 10, 20, 30"));
216 ATF_REQUIRE_EQ(0, state.get_top());
223 lutok::state state;
224 ATF_REQUIRE_EQ(2, lutok::do_string(state, "return 10, 20, 30", 2));
225 ATF_REQUIRE_EQ(2, state.get_top());
226 ATF_REQUIRE_EQ(10, state.to_integer(-2));
227 ATF_REQUIRE_EQ(20, state.to_integer(-1));
228 state.pop(2);
235 lutok::state state;
236 stack_balance_checker checker(state);
238 lutok::do_string(state, "a b c"));
245 lutok::state state;
246 stack_balance_checker checker(state);
247 lutok::eval(state, "3 + 10");
248 ATF_REQUIRE_EQ(13, state.to_integer());
249 state.pop(1);
256 lutok::state state;
257 stack_balance_checker checker(state);
258 lutok::eval(state, "5, 8, 10", 3);
259 ATF_REQUIRE_EQ(5, state.to_integer(-3));
260 ATF_REQUIRE_EQ(8, state.to_integer(-2));
261 ATF_REQUIRE_EQ(10, state.to_integer(-1));
262 state.pop(3);
269 lutok::state state;
270 stack_balance_checker checker(state);
272 lutok::eval(state, "non_existent.method()"));