updated the examples to work among other things
[luabind.git] / test / test_scope.cpp
blob2fdcebaf93668210a2ad022b51faedb346199370
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 g()
15 feedback = 2;
18 struct test_class
20 test_class()
22 feedback = 321;
27 bool test_scope()
29 using namespace luabind;
31 lua_State* L = lua_open();
32 lua_closer c(L);
34 open(L);
36 namespace_(L, "test")
38 class_<test_class>("test_class")
39 .def(constructor<>())
40 .enum_("vals")
42 value("val1", 1),
43 value("val2", 2)
46 def("f", &f),
48 namespace_("inner")
50 def("g", &g)
55 if (dostring(L, "test.f()")) return false;
56 if (feedback != 123) return false;
57 if (dostring(L, "a = test.test_class()")) return false;
58 if (feedback != 321) return false;
59 if (dostring(L, "b = test.test_class.val2")) return false;
60 if (dostring(L, "test.inner.g()")) return false;
61 if (feedback != 2) return false;
64 return true;