Update of /cvsroot/luabind/luabind/luabind/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29574/test
Modified Files:
Tag: daniel-refactoring
Jamfile test_lua_classes.cpp test_value_wrapper.cpp
Added Files:
Tag: daniel-refactoring
test_back_reference.cpp test_def_from_base.cpp
test_has_get_pointer.cpp
Log Message:
merged_beta7-devel2_into_daniel-refactoring_051024
--- NEW FILE: test_def_from_base.cpp ---
// Copyright (c) 2005 Daniel Wallin, Arvid Norberg
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
// SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
// ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
// OR OTHER DEALINGS IN THE SOFTWARE.
#include "test.hpp"
#include <luabind/luabind.hpp>
struct V
{
int f(int,int)
{
return 2;
}
};
struct W : V
{};
void test_main(lua_State* L)
{
using namespace luabind;
module(L)
[
class_<W>("W")
.def(constructor<>())
.def("f", &V::f)
];
DOSTRING(L,
"x = W()\n"
"assert(x:f(1,2) == 2)\n"
);
}
--- NEW FILE: test_has_get_pointer.cpp ---
// Copyright (c) 2005 Daniel Wallin
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
// SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
// ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
// OR OTHER DEALINGS IN THE SOFTWARE.
#include <luabind/detail/has_get_pointer.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/get_pointer.hpp>
namespace lb = luabind::detail;
namespace test
{
struct X
{
};
struct Y
{
};
Y* get_pointer(Y const&);
} // namespace test
#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
namespace luabind
{
using test::get_pointer;
using boost::get_pointer;
} // namespace luabind
#endif
BOOST_MPL_ASSERT(( lb::has_get_pointer<boost::shared_ptr<int> > ));
BOOST_MPL_ASSERT(( lb::has_get_pointer<test::Y> ));
BOOST_MPL_ASSERT(( lb::has_get_pointer<char*> ));
BOOST_MPL_ASSERT_NOT(( lb::has_get_pointer<int> ));
BOOST_MPL_ASSERT_NOT(( lb::has_get_pointer<test::X> ));
Index: Jamfile
===================================================================
RCS file: /cvsroot/luabind/luabind/luabind/test/Jamfile,v
retrieving revision 1.15.2.3
retrieving revision 1.15.2.3.2.1
diff -u -d -r1.15.2.3 -r1.15.2.3.2.1
--- Jamfile 30 Sep 2005 09:19:29 -0000 1.15.2.3
+++ Jamfile 24 Oct 2005 00:31:35 -0000 1.15.2.3.2.1
@@ -3,6 +3,8 @@
use-project /luabind : ../ ;
SOURCES =
+ test_back_reference.cpp
+ test_def_from_base.cpp
test_object.cpp
test_abstract_base.cpp
test_attributes.cpp
@@ -21,7 +23,6 @@
test_separation.cpp
test_simple_class.cpp
test_yield.cpp
- test_value_wrapper.cpp
;
project : default-build <link>static ;
@@ -38,5 +39,9 @@
tests += [ run $(src) main-lib ] ;
}
-test-suite luabind-test : $(tests) [ compile test_typetraits.cpp ] ;
+test-suite luabind-test : $(tests)
+ [ compile test_typetraits.cpp ]
+ [ compile test_value_wrapper.cpp ]
+ [ compile test_has_get_pointer.cpp ]
+ ;
Index: test_lua_classes.cpp
===================================================================
RCS file: /cvsroot/luabind/luabind/luabind/test/test_lua_classes.cpp,v
retrieving revision 1.26.2.2
retrieving revision 1.26.2.2.2.1
diff -u -d -r1.26.2.2 -r1.26.2.2.2.1
--- test_lua_classes.cpp 29 Jul 2005 02:41:02 -0000 1.26.2.2
+++ test_lua_classes.cpp 24 Oct 2005 00:31:35 -0000 1.26.2.2.2.1
@@ -165,22 +165,12 @@
.def("f", &U::f)
.def("g", &U::g)
];
-
- try
- {
- dostring(L, "u = U()\n"
+
+ DOSTRING(L,
+ "u = U()\n"
"assert(u:f(0) == 1)\n"
"assert(u:f(0,0) == 2)\n"
"assert(u:g() == 3)\n");
- }
- catch (luabind::error const& e)
- {
- TEST_ERROR(lua_tostring(e.state(), -1));
- }
- catch (std::string const& s)
- {
- TEST_ERROR(s.c_str());
- }
DOSTRING(L,
"u = U()\n"
Index: test_value_wrapper.cpp
===================================================================
RCS file: /cvsroot/luabind/luabind/luabind/test/Attic/test_value_wrapper.cpp,v
retrieving revision 1.1.2.1.2.1
retrieving revision 1.1.2.1.2.2
diff -u -d -r1.1.2.1.2.1 -r1.1.2.1.2.2
--- test_value_wrapper.cpp 10 Oct 2005 08:55:05 -0000 1.1.2.1.2.1
+++ test_value_wrapper.cpp 24 Oct 2005 00:31:35 -0000 1.1.2.1.2.2
@@ -21,6 +21,7 @@
// OR OTHER DEALINGS IN THE SOFTWARE.
#include <luabind/value_wrapper.hpp>
+#include <luabind/object.hpp>
#include <boost/mpl/assert.hpp>
struct X_tag;
@@ -32,24 +33,27 @@
namespace luabind
{
-
+#ifdef LUABIND_USE_VALUE_WRAPPER_TAG
template<>
struct value_wrapper_traits<X_tag>
{
typedef boost::mpl::true_ is_specialized;
};
-
+#else
// used on compilers supporting partial template specialization
template<>
struct value_wrapper_traits<X>
{
typedef boost::mpl::true_ is_specialized;
};
-
+#endif
} // namespace luabind
BOOST_MPL_ASSERT(( luabind::is_value_wrapper<X> ));
+BOOST_MPL_ASSERT_NOT(( luabind::is_value_wrapper<X&> ));
+BOOST_MPL_ASSERT_NOT(( luabind::is_value_wrapper<X const&> ));
+
BOOST_MPL_ASSERT(( luabind::is_value_wrapper_arg<X> ));
BOOST_MPL_ASSERT(( luabind::is_value_wrapper_arg<X const> ));
BOOST_MPL_ASSERT(( luabind::is_value_wrapper_arg<X&> ));
@@ -57,8 +61,9 @@
BOOST_MPL_ASSERT_NOT(( luabind::is_value_wrapper_arg<int> ));
BOOST_MPL_ASSERT_NOT(( luabind::is_value_wrapper_arg<int[4]> ));
-BOOST_MPL_ASSERT_NOT(( luabind::is_value_wrapper<X&> ));
-BOOST_MPL_ASSERT_NOT(( luabind::is_value_wrapper<X const&> ));
+BOOST_MPL_ASSERT(( luabind::is_value_wrapper_arg<X const&> ));
+BOOST_MPL_ASSERT(( luabind::is_value_wrapper_arg<luabind::object&> ));
+BOOST_MPL_ASSERT(( luabind::is_value_wrapper_arg<luabind::object const&> ));
int main()
{
--- NEW FILE: test_back_reference.cpp ---
// Copyright (c) 2005 Daniel Wallin
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
// SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
// ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
// OR OTHER DEALINGS IN THE SOFTWARE.
#include "test.hpp"
#include <luabind/luabind.hpp>
#include <boost/shared_ptr.hpp>
using namespace luabind;
#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
namespace luabind
{
using boost::get_pointer;
}
#endif
namespace luabind
{
template<class T>
boost::shared_ptr<T const>* get_const_holder(boost::shared_ptr<T>*)
{
return 0;
}
}
struct base0
{
virtual ~base0() {}
};
struct base_wrap0 : base0, wrap_base
{};
struct base1
{
virtual ~base1() {}
};
struct base_wrap1 : base1, wrap_base
{};
base0* filter0(base0* p)
{
return p;
}
boost::shared_ptr<base1> filter1(boost::shared_ptr<base1> const& p)
{
return p;
}
void test_main(lua_State* L)
{
module(L)
[
class_<base0, base_wrap0>("base0")
.def(constructor<>()),
def("filter0", &filter0),
class_<base1, base_wrap1, boost::shared_ptr<base1> >("base1")
.def(constructor<>()),
def("filter1", &filter1)
];
DOSTRING(L,
"class 'derived0' (base0)\n"
" function derived0:__init()\n"
" super()\n"
" end\n"
"class 'derived1' (base1)\n"
" function derived1:__init()\n"
" super()\n"
" end\n"
);
DOSTRING(L,
"x = derived0()\n"
"y = filter0(x)\n"
"assert(x == y)\n"
);
DOSTRING(L,
"x = derived1()\n"
"y = filter1(x)\n"
"assert(x == y)\n"
);
}
|