*** empty log message ***
[luabind.git] / test / test_null_pointer.cpp
blob9466796b2edc73b7f64949eccd52109b51e3c479
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 module(L)
31 class_<A>("A")
32 .def(constructor<>())
33 .def("f", &A::f),
35 def("get_pointer", get_pointer)
37 if (dostring(L, "e = get_pointer()")) return false;
39 lua_pushstring(L, "e");
40 lua_gettable(L, LUA_GLOBALSINDEX);
41 if (!lua_isnil(L, -1)) return false;
42 lua_pop(L, 1);
44 if (dostring(L, "a = A() e = a:f()")) return false;
45 lua_pushstring(L, "e");
46 lua_gettable(L, LUA_GLOBALSINDEX);
47 if (!lua_isnil(L, -1)) return false;
48 lua_pop(L, 1);
50 if (top != lua_gettop(L)) return false;
52 return true;