*** empty log message ***
[luabind.git] / test / test_const.cpp
blob430eda35daa2dd804d1e1b0c7ca1bc6bd696d969
1 // Copyright (c) 2004 Daniel Wallin and Arvid Norberg
3 // Permission is hereby granted, free of charge, to any person obtaining a
4 // copy of this software and associated documentation files (the "Software"),
5 // to deal in the Software without restriction, including without limitation
6 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 // and/or sell copies of the Software, and to permit persons to whom the
8 // Software is furnished to do so, subject to the following conditions:
10 // The above copyright notice and this permission notice shall be included
11 // in all copies or substantial portions of the Software.
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
14 // ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
15 // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
16 // PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
17 // SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
18 // ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
21 // OR OTHER DEALINGS IN THE SOFTWARE.
23 #include "test.hpp"
24 #include <luabind/luabind.hpp>
26 namespace {
28 struct A
30 const A* f() { return this; }
32 int g1() const { return 1; }
33 int g2() { return 2; }
36 } // anonymous namespace
38 void test_const()
40 lua_state L;
42 using namespace luabind;
44 module(L)
46 class_<A>("A")
47 .def(constructor<>())
48 .def("f", &A::f)
49 .def("g", &A::g1)
50 .def("g", &A::g2)
53 DOSTRING(L, "a = A()");
54 DOSTRING(L, "assert(a:g() == 2)");
56 DOSTRING(L, "a2 = a:f()");
57 DOSTRING(L, "assert(a2:g() == 1)");