13 #include <luabind/luabind.hpp>
14 #include <luabind/scope.hpp>
16 bool dostring(lua_State
* L
, const char* str
)
18 if (luaL_loadbuffer(L
, str
, std::strlen(str
), str
) || lua_pcall(L
, 0, 0, 0))
20 const char* a
= lua_tostring(L
, -1);
21 std::cout
<< a
<< "\n";
28 int dostring2(lua_State
* L
, const char* str
)
30 if (luaL_loadbuffer(L
, str
, std::strlen(str
), str
) || lua_pcall(L
, 0, 0, 0))
37 bool report_success(bool result
, const char* name
)
41 if (result
) std::cout
<< ": passed\n";
42 else std::cout
<< ": failed\n";
44 if (result
) std::cout
<< ": \033[32mpassed\033[0m\n";
45 else std::cout
<< ": \033[31mfailed\033[0m\n";
54 passed
&= report_success(test_construction(), "construction");
55 passed
&= report_success(test_attributes(), "attributes");
56 passed
&= report_success(test_operators(), "operators");
57 passed
&= report_success(test_implicit_cast(), "implicit cast");
58 passed
&= report_success(test_const(), "const");
59 #ifndef LUABIND_NO_EXCEPTIONS
60 passed
&= report_success(test_exceptions(), "exceptions");
62 std::cout
<< "exceptions: skipped \n";
64 passed
&= report_success(test_null_pointer(), "null pointer");
65 passed
&= report_success(test_policies(), "policies");
66 passed
&= report_success(test_lua_classes(), "lua classes");
67 passed
&= report_success(test_free_functions(), "free functions");
68 passed
&= report_success(test_object(), "object");
69 passed
&= report_success(test_held_type(), "held type");
70 passed
&= report_success(test_iterator(), "iterator");
71 passed
&= report_success(test_scope(), "scopes");
72 passed
&= report_success(test_yield(), "yield");
74 if (passed
) std::cout
<< "\n\nall tests passed\n";
75 else std::cout
<< "\n\nsome tests failed\n";