*** empty log message ***
[luabind.git] / test / test_const.cpp
blob76e87aa24a718c5f3ca7ddc80a0473975744f150
1 #include "test.h"
3 namespace
5 LUABIND_ANONYMOUS_FIX int feedback = 0;
7 struct A
9 const A* f() { return this; }
11 void g() const { feedback = 1; }
12 void g() { feedback = 2; }
15 } // anonymous namespace
17 bool test_const()
19 using namespace luabind;
21 lua_State* L = lua_open();
22 lua_closer c(L);
23 int top = lua_gettop(L);
25 open(L);
27 typedef void(A::*g1_t)();
28 typedef void(A::*g2_t)() const;
30 g1_t g1 = &A::g;
31 g2_t g2 = &A::g;
33 class_<A>(L, "A")
34 .def(constructor<>())
35 .def("f", &A::f)
36 .def("g", /*(void(A::*)() const) &A::g*/ g1)
37 .def("g", /*(void(A::*)()) &A::g*/ g2);
39 if (dostring(L, "a = A()")) return false;
40 if (dostring(L, "a:g()")) return false;
41 if (feedback != 2) return false;
43 if (dostring(L, "a2 = a:f()")) return false;
44 if (dostring(L, "a2:g()")) return false;
45 if (feedback != 1) return false;
47 if (top != lua_gettop(L)) return false;
49 return true;