Update of /cvsroot/luabind/luabind/luabind/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17155/test
Modified Files:
test.hpp test_free_functions.cpp
Log Message:
added a primitive converter for objects of type LUA_TTHREAD to lua_State*. Fixed bug in class_info.cpp. added stack pops ti test.hpp where a test would fail, it still preserve the stack now. Removed obsolete tests of functor and added a test of call_function where the function that is called fails.
Index: test_free_functions.cpp
===================================================================
RCS file: /cvsroot/luabind/luabind/luabind/test/test_free_functions.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- test_free_functions.cpp 28 Nov 2005 20:55:34 -0000 1.19
+++ test_free_functions.cpp 26 Mar 2006 20:34:13 -0000 1.20
@@ -22,16 +22,7 @@
#include "test.hpp"
#include <luabind/luabind.hpp>
-//#include <luabind/functor.hpp>
#include <luabind/adopt_policy.hpp>
-/*
-luabind::functor<int> functor_test;
-
-void set_functor(luabind::functor<int> f)
-{
- functor_test = f;
-}
-*/
struct base : counted_type<base>
{
@@ -166,17 +157,22 @@
"f(number)\n"
"f(number, number)\n");
-// DOSTRING(L,
-// "function functor_test(a) glob = a\n"
-// " return 'foobar'\n"
-// "end");
-// functor<std::string> functor_test = object_cast<functor<std::string> >(globals(L)["functor_test"]);
-
-// TEST_CHECK(functor_test(6)[detail::null_type()] == "foobar");
-// TEST_CHECK(object_cast<int>(globals(L)["glob"]) == 6);
-// functor<std::string> functor_test2 = object_cast<functor<std::string> >(globals(L)["functor_test"]);
+ DOSTRING(L, "function failing_fun() error('expected error message') end");
+ try
+ {
+ call_function<void>(L, "failing_fun");
+ TEST_ERROR("function didn't fail when it was expected to");
+ }
+ catch(luabind::error const& e)
+ {
+ if (std::string("[string \"function failing_fun() error('expected "
+ "erro...\"]:1: expected error message") != lua_tostring(L, -1))
+ {
+ TEST_ERROR("function failed with unexpected error message");
+ lua_pop(L, 1);
+ }
+ }
-// TEST_CHECK(functor_test == functor_test2);
}
Index: test.hpp
===================================================================
RCS file: /cvsroot/luabind/luabind/luabind/test/test.hpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- test.hpp 28 Nov 2005 20:55:34 -0000 1.9
+++ test.hpp 26 Mar 2006 20:34:13 -0000 1.10
@@ -108,12 +108,13 @@
, (char const*)expected)) \
{ \
TEST_ERROR(lua_tostring(e.state(), -1)); \
+ lua_pop(L, 1); \
} \
} \
catch (std::string const& s) \
{ \
if (s != expected) \
- TEST_ERROR(s.c_str()); \
+ TEST_ERROR(s.c_str()); \
} \
}
@@ -126,6 +127,7 @@
catch (luabind::error const& e) \
{ \
TEST_ERROR(lua_tostring(e.state(), -1)); \
+ lua_pop(L, 1); \
} \
catch (std::string const& s) \
{ \
|