*** empty log message ***
[luabind.git] / test / test_null_pointer.cpp
blob6fccbab82097fbdf03b68e05f2466b4f23825a20
1 #include "test.h"
3 namespace
6 struct A
8 A* f() { return 0; }
9 };
11 A* get_pointer()
13 return 0;
16 } // anonymous namespace
19 bool test_null_pointer()
21 using namespace luabind;
23 lua_State* L = lua_open();
24 lua_closer c(L);
25 int top = lua_gettop(L);
27 open(L);
29 class_<A>(L, "A")
30 .def(constructor<>())
31 .def("f", &A::f);
33 function(L, "get_pointer", get_pointer);
34 if (dostring(L, "e = get_pointer()")) return false;
36 lua_pushstring(L, "e");
37 lua_gettable(L, LUA_GLOBALSINDEX);
38 if (!lua_isnil(L, -1)) return false;
39 lua_pop(L, 1);
41 if (dostring(L, "a = A() e = a:f()")) return false;
42 lua_pushstring(L, "e");
43 lua_gettable(L, LUA_GLOBALSINDEX);
44 if (!lua_isnil(L, -1)) return false;
45 lua_pop(L, 1);
47 if (top != lua_gettop(L)) return false;
49 return true;