fixed correct function overloading with scopes.
[luabind.git] / test / test_scope.cpp
blobb595663c2765ac2dea94061064f33e93e2b97dc8
1 #include "test.h"
2 #include <luabind/functor.hpp>
4 namespace
6 LUABIND_ANONYMOUS_FIX int feedback = 0;
8 void f()
10 feedback = 123;
13 void f_(int a)
15 feedback = 124;
18 void f__(int a)
20 feedback = 125;
23 void g()
25 feedback = 2;
28 struct test_class
30 test_class()
32 feedback = 321;
37 bool test_scope()
39 using namespace luabind;
41 lua_State* L = lua_open();
42 lua_closer c(L);
44 open(L);
46 module(L, "test")
48 class_<test_class>("test_class")
49 .def(constructor<>())
50 .enum_("vals")
52 value("val1", 1),
53 value("val2", 2)
56 def("f", &f),
57 def("f", &f_),
59 namespace_("inner")
61 def("g", &g),
62 def("f", &f__)
67 if (dostring(L, "test.f()")) return false;
68 if (feedback != 123) return false;
69 if (dostring(L, "test.f(3)")) return false;
70 if (feedback != 124) return false;
71 if (dostring(L, "a = test.test_class()")) return false;
72 if (feedback != 321) return false;
73 if (dostring(L, "b = test.test_class.val2")) return false;
74 if (dostring(L, "test.inner.g()")) return false;
75 if (feedback != 2) return false;
76 if (dostring(L, "test.inner.f(4)")) return false;
77 if (feedback != 125) return false;
80 return true;