*** empty log message ***
[luabind.git] / test / test_const.cpp
blobfc8fe79532b6dce88ed0c18b49aff8267c40f380
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 module(L)
35 class_<A>("A")
36 .def(constructor<>())
37 .def("f", &A::f)
38 .def("g", /*(void(A::*)() const) &A::g*/ g1)
39 .def("g", /*(void(A::*)()) &A::g*/ g2)
42 if (dostring(L, "a = A()")) return false;
43 if (dostring(L, "a:g()")) return false;
44 if (feedback != 2) return false;
46 if (dostring(L, "a2 = a:f()")) return false;
47 if (dostring(L, "a2:g()")) return false;
48 if (feedback != 1) return false;
50 if (top != lua_gettop(L)) return false;
52 return true;