14 struct operator_tester
16 int operator+(int) const
22 float operator-() const
28 float operator()() const
34 float operator()(int a
) const
40 float operator()(int a
)
48 int operator+(int, const operator_tester
&)
54 struct operator_tester2
58 float operator+(const operator_tester
&, const operator_tester2
&)
64 struct operator_tester3
: public operator_tester
{};
66 const operator_tester
* make_const_test()
68 static operator_tester o
;
72 std::ostream
& operator<<(std::ostream
& os
, const operator_tester
&)
74 os
<< "operator_tester"; feedback
= 63; return os
;
77 } // anonymous namespace
81 using namespace luabind
;
83 lua_State
* L
= lua_open();
87 int top
= lua_gettop(L
);
91 if (feedback
!= 0) return false;
93 class_
<operator_tester
>(L
, "operator_tester")
95 .def(tostring(const_self
))
97 .def(other
<int>() + self
)
100 .def(const_self(int()))
104 class_
<operator_tester2
>(L
, "operator_tester2")
105 .def(constructor
<>())
106 .def(other
<const operator_tester
&>() + self
);
108 class_
<operator_tester3
, bases
<operator_tester
> >(L
, "operator_tester3")
109 .def(constructor
<>());
112 function(L
, "make_const_test", &make_const_test
);
114 if (feedback
!= 0) return false;
116 if (dostring(L
, "test = operator_tester()")) return false;
117 if (dostring(L
, "test2 = operator_tester2()")) return false;
118 if (dostring(L
, "test3 = operator_tester3()")) return false;
120 if (dostring(L
, "test()")) return false;
121 if (feedback
!= 3) return false;
122 if (dostring(L
, "test(5)")) return false;
123 if (feedback
!= 7) return false;
125 dostring(L
, "const_test = make_const_test()");
126 if (dostring(L
, "const_test(5)")) return false;
127 if (feedback
!= 4) return false;
129 if (dostring(L
, "a = -test")) return false;
130 if (feedback
!= 2) return false;
132 if (dostring(L
, "a = test + test2")) return false;
133 if (feedback
!= 6) return false;
135 if (dostring(L
, "a = 2 + test")) return false;
136 if (feedback
!= 5) return false;
138 if (dostring(L
, "a = test + 2")) return false;
139 if (feedback
!= 1) return false;
141 if (dostring(L
, "a = test3 + 6")) return false;
142 if (feedback
!= 1) return false;
144 if (dostring(L
, "a = test3 + test2")) return false;
145 if (feedback
!= 6) return false;
147 if (dostring(L
, "a = tostring(test)")) return false;
148 if (feedback
!= 63) return false;
150 if (top
!= lua_gettop(L
)) return false;