From 7b725df67e8d84f789e8fcc3a38610debb78e437 Mon Sep 17 00:00:00 2001 From: Daniel Wallin Date: Thu, 29 Jan 2009 14:10:55 +0100 Subject: [PATCH] Add test for "class_info()". --- test/Jamfile | 1 + test/test_class_info.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 test/test_class_info.cpp diff --git a/test/Jamfile b/test/Jamfile index bbf85fa..9340fbd 100755 --- a/test/Jamfile +++ b/test/Jamfile @@ -31,6 +31,7 @@ SOURCES = test_user_defined_converter.cpp test_adopt_wrapper.cpp test_builtin_converters.cpp + test_class_info.cpp ; obj main : main.cpp : ..//luabind : : ..//luabind ; diff --git a/test/test_class_info.cpp b/test/test_class_info.cpp new file mode 100644 index 0000000..4356948 --- /dev/null +++ b/test/test_class_info.cpp @@ -0,0 +1,41 @@ +// Copyright Daniel Wallin 2009. Use, modification and distribution is +// subject to the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#include "test.hpp" +#include +#include + +struct X +{ + void f() + {} + + int x; + int y; +}; + +void test_main(lua_State* L) +{ + using namespace luabind; + + bind_class_info(L); + + module(L) [ + class_("X") + .def(constructor<>()) + .def("f", &X::f) + .def_readonly("x", &X::x) + .def_readonly("y", &X::y) + ]; + + DOSTRING(L, + "x = X()\n" + "info = class_info(x)\n" + "assert(info.name == 'X')\n" + "assert(info.methods['f'] == x.f)\n" + "assert(info.methods['__init'] == x.__init)\n" + "assert(info.attributes[1] == 'y')\n" + "assert(info.attributes[2] == 'x')\n" + ); +} -- 2.11.4.GIT