test_set_instance_value.cpp 833 B

123456789101112131415161718192021222324252627282930
  1. // Copyright Daniel Wallin 2009. Use, modification and distribution is
  2. // subject to the Boost Software License, Version 1.0. (See accompanying
  3. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  4. #include "test.hpp"
  5. #include <luabind/luabind.hpp>
  6. void test_main(lua_State* L)
  7. {
  8. DOSTRING(L,
  9. "class 'X'\n"
  10. " function X:__init()\n"
  11. " self.value = 1\n"
  12. " self.second = 2\n"
  13. " end\n"
  14. "\n"
  15. "x = X()\n"
  16. "assert(x.value == 1)\n"
  17. "assert(x.second == 2)\n"
  18. "x.value = 2\n"
  19. "assert(x.value == 2)\n"
  20. "assert(x.second == 2)\n"
  21. "x.second = 3\n"
  22. "y = X()\n"
  23. "assert(y.value == 1)\n"
  24. "assert(y.second == 2)\n"
  25. "assert(x.value == 2)\n"
  26. "assert(x.second == 3)\n"
  27. );
  28. }