|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r50085 - in sandbox/mirror: boost/mirror boost/mirror/concept libs/mirror/test
From: chochlik_at_[hidden]
Date: 2008-12-03 11:39:09
Author: matus.chochlik
Date: 2008-12-03 11:39:07 EST (Wed, 03 Dec 2008)
New Revision: 50085
URL: http://svn.boost.org/trac/boost/changeset/50085
Log:
[mirror 0.3.x]
- Added concept conformance checks to the testsuite
Added:
sandbox/mirror/boost/mirror/concept/
sandbox/mirror/boost/mirror/concept.hpp (contents, props changed)
sandbox/mirror/boost/mirror/concept/MetaClass.hpp (contents, props changed)
sandbox/mirror/boost/mirror/concept/MetaNamedObject.hpp (contents, props changed)
sandbox/mirror/boost/mirror/concept/MetaNamedScopedObject.hpp (contents, props changed)
sandbox/mirror/boost/mirror/concept/MetaNamespace.hpp (contents, props changed)
sandbox/mirror/boost/mirror/concept/MetaObject.hpp (contents, props changed)
sandbox/mirror/boost/mirror/concept/MetaScope.hpp (contents, props changed)
sandbox/mirror/boost/mirror/concept/MetaScopedObject.hpp (contents, props changed)
sandbox/mirror/boost/mirror/concept/MetaType.hpp (contents, props changed)
sandbox/mirror/boost/mirror/concept/utils.hpp (contents, props changed)
sandbox/mirror/libs/mirror/test/concepts_ct_01.cpp (contents, props changed)
sandbox/mirror/libs/mirror/test/concepts_ct_02.cpp (contents, props changed)
sandbox/mirror/libs/mirror/test/concepts_ct_03.cpp (contents, props changed)
Text files modified:
sandbox/mirror/libs/mirror/test/Jamfile.v2 | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
Added: sandbox/mirror/boost/mirror/concept.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/concept.hpp 2008-12-03 11:39:07 EST (Wed, 03 Dec 2008)
@@ -0,0 +1,29 @@
+/**
+ * \file boost/mirror/concept.hpp
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under 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)
+ */
+
+#ifndef BOOST_MIRROR_CONCEPT_HPP
+#define BOOST_MIRROR_CONCEPT_HPP
+
+#include <boost/mirror/concept/MetaObject.hpp>
+#include <boost/mirror/concept/MetaScopedObject.hpp>
+#include <boost/mirror/concept/MetaNamedObject.hpp>
+#include <boost/mirror/concept/MetaScope.hpp>
+#include <boost/mirror/concept/MetaNamedScopedObject.hpp>
+#include <boost/mirror/concept/MetaNamespace.hpp>
+#include <boost/mirror/concept/MetaType.hpp>
+#include <boost/mirror/concept/MetaClass.hpp>
+
+namespace boost {
+namespace mirror {
+
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+
Added: sandbox/mirror/boost/mirror/concept/MetaClass.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/concept/MetaClass.hpp 2008-12-03 11:39:07 EST (Wed, 03 Dec 2008)
@@ -0,0 +1,48 @@
+/**
+ * \file boost/mirror/concept/MetaClass.hpp
+ *
+ * Meta function checking whether a given type satisfies the
+ * requirements of the MetaClass concept
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under 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)
+ */
+
+#ifndef BOOST_MIRROR_CONCEPT_META_CLASS_HPP
+#define BOOST_MIRROR_CONCEPT_META_CLASS_HPP
+
+#include <boost/mirror/concept/MetaType.hpp>
+#include <boost/mirror/concept/MetaScope.hpp>
+
+namespace boost {
+namespace mirror {
+
+template <typename T>
+struct is_MetaClass
+{
+ BOOST_MIRROR_CONCEPT_TESTER_BEGIN
+
+ template <class X>
+ static match test(
+ X*,
+ typename X::base_classes* _x1 = 0,
+ typename X::attributes * _x2 = 0,
+ typename X::all_attributes * _x3 = 0
+ );
+
+ typedef typename mpl::and_<
+ typename is_MetaType<T>::type,
+ typename is_MetaScope<T>::type
+ >::type other_constraints;
+
+ BOOST_MIRROR_CONCEPT_TESTER_END
+
+};
+
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+
Added: sandbox/mirror/boost/mirror/concept/MetaNamedObject.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/concept/MetaNamedObject.hpp 2008-12-03 11:39:07 EST (Wed, 03 Dec 2008)
@@ -0,0 +1,47 @@
+/**
+ * \file boost/mirror/concept/MetaNamedObject.hpp
+ *
+ * Meta function checking whether a given type satisfies the
+ * requirements of the MetaNamedObject concept
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under 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)
+ */
+
+#ifndef BOOST_MIRROR_CONCEPT_META_NAMED_OBJECT_HPP
+#define BOOST_MIRROR_CONCEPT_META_NAMED_OBJECT_HPP
+
+#include <boost/mirror/concept/MetaObject.hpp>
+
+namespace boost {
+namespace mirror {
+
+template <typename T>
+struct is_MetaNamedObject
+{
+ BOOST_MIRROR_CONCEPT_TESTER_BEGIN
+
+ template <class X>
+ static match test(
+ X*,
+ // check for base_name member function
+ const ::boost::cts::bstring* _y1 = &X::base_name(),
+ // check for get_name member function
+ const ::std::string* _y2 = &X::get_name(mpl::false_(), ::std::char_traits<char>()),
+ const ::std::wstring* _y3 = &X::get_name(mpl::false_(), ::std::char_traits<wchar_t>())
+ );
+
+ typedef is_MetaObject<T> other_constraints;
+
+ BOOST_MIRROR_CONCEPT_TESTER_END
+
+};
+
+
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+
Added: sandbox/mirror/boost/mirror/concept/MetaNamedScopedObject.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/concept/MetaNamedScopedObject.hpp 2008-12-03 11:39:07 EST (Wed, 03 Dec 2008)
@@ -0,0 +1,49 @@
+/**
+ * \file boost/mirror/concept/MetaNamedScopedObject.hpp
+ *
+ * Meta function checking whether a given type satisfies the
+ * requirements of the MetaNamedObject concept
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under 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)
+ */
+
+#ifndef BOOST_MIRROR_CONCEPT_META_NAMED_SCOPED_OBJECT_HPP
+#define BOOST_MIRROR_CONCEPT_META_NAMED_SCOPED_OBJECT_HPP
+
+#include <boost/mirror/concept/MetaNamedObject.hpp>
+#include <boost/mirror/concept/MetaScopedObject.hpp>
+
+namespace boost {
+namespace mirror {
+
+
+template <typename T>
+struct is_MetaNamedScopedObject
+{
+ BOOST_MIRROR_CONCEPT_TESTER_BEGIN
+
+ template <class X>
+ static match test(
+ X*,
+ // check for full_name member function
+ const ::boost::cts::bstring* _y1 = &X::full_name()
+ );
+
+ typedef typename mpl::and_<
+ typename is_MetaScopedObject<T>::type,
+ typename is_MetaNamedObject<T>::type
+ >::type other_constraints;
+
+ BOOST_MIRROR_CONCEPT_TESTER_END
+
+};
+
+
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+
Added: sandbox/mirror/boost/mirror/concept/MetaNamespace.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/concept/MetaNamespace.hpp 2008-12-03 11:39:07 EST (Wed, 03 Dec 2008)
@@ -0,0 +1,46 @@
+/**
+ * \file boost/mirror/concept/MetaNamespace.hpp
+ *
+ * Meta function checking whether a given type satisfies the
+ * requirements of the MetaNamespace concept
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under 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)
+ */
+
+#ifndef BOOST_MIRROR_CONCEPT_META_NAMESPACE_HPP
+#define BOOST_MIRROR_CONCEPT_META_NAMESPACE_HPP
+
+#include <boost/mirror/concept/MetaNamedScopedObject.hpp>
+
+namespace boost {
+namespace mirror {
+
+template <typename T>
+struct is_MetaNamespace
+{
+ BOOST_MIRROR_CONCEPT_TESTER_BEGIN
+
+ template <class X>
+ static match test(
+ X*,
+ // check for ancestors typedef
+ typename X::ancestors* _x = 0
+ );
+
+ typedef typename mpl::and_<
+ is_MetaNamedScopedObject<T>,
+ is_MetaScope<T>
+ >::type other_constraints;
+
+ BOOST_MIRROR_CONCEPT_TESTER_END
+
+};
+
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+
Added: sandbox/mirror/boost/mirror/concept/MetaObject.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/concept/MetaObject.hpp 2008-12-03 11:39:07 EST (Wed, 03 Dec 2008)
@@ -0,0 +1,42 @@
+/**
+ * \file boost/mirror/concept/MetaObject.hpp
+ *
+ * Meta function checking whether a given type satisfies the
+ * requirements of the MetaObject concept
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under 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)
+ */
+
+#ifndef BOOST_MIRROR_CONCEPT_META_OBJECT_HPP
+#define BOOST_MIRROR_CONCEPT_META_OBJECT_HPP
+
+#include <boost/mirror/concept/utils.hpp>
+
+namespace boost {
+namespace mirror {
+
+template <typename T>
+struct is_MetaObject
+{
+ BOOST_MIRROR_CONCEPT_TESTER_BEGIN
+
+ template <class X>
+ static match test(
+ X*
+ );
+
+ typedef mpl::true_ other_constraints;
+
+ BOOST_MIRROR_CONCEPT_TESTER_END
+
+};
+
+
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+
Added: sandbox/mirror/boost/mirror/concept/MetaScope.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/concept/MetaScope.hpp 2008-12-03 11:39:07 EST (Wed, 03 Dec 2008)
@@ -0,0 +1,44 @@
+/**
+ * \file boost/mirror/concept/MetaScope.hpp
+ *
+ * Meta function checking whether a given type satisfies the
+ * requirements of the MetaScope concept
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under 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)
+ */
+
+#ifndef BOOST_MIRROR_CONCEPT_META_SCOPE_HPP
+#define BOOST_MIRROR_CONCEPT_META_SCOPE_HPP
+
+#include <boost/mirror/concept/MetaNamedObject.hpp>
+
+namespace boost {
+namespace mirror {
+
+
+template <typename T>
+struct is_MetaScope
+{
+ BOOST_MIRROR_CONCEPT_TESTER_BEGIN
+
+ template <class X>
+ static match test(
+ X*
+ );
+
+ typedef typename is_MetaNamedObject<T>::type
+ other_constraints;
+
+ BOOST_MIRROR_CONCEPT_TESTER_END
+
+};
+
+
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+
Added: sandbox/mirror/boost/mirror/concept/MetaScopedObject.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/concept/MetaScopedObject.hpp 2008-12-03 11:39:07 EST (Wed, 03 Dec 2008)
@@ -0,0 +1,43 @@
+/**
+ * \file boost/mirror/concept/MetaScopedObject.hpp
+ *
+ * Meta function checking whether a given type satisfies the
+ * requirements of the MetaScopedObject concept
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under 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)
+ */
+
+#ifndef BOOST_MIRROR_CONCEPT_META_SCOPED_OBJECT_HPP
+#define BOOST_MIRROR_CONCEPT_META_SCOPED_OBJECT_HPP
+
+#include <boost/mirror/concept/MetaObject.hpp>
+
+namespace boost {
+namespace mirror {
+
+template <typename T>
+struct is_MetaScopedObject
+{
+ BOOST_MIRROR_CONCEPT_TESTER_BEGIN
+
+ template <class X>
+ static match test(
+ X*,
+ // check for scope typedef
+ typename X::scope* _x = 0
+ );
+
+ typedef is_MetaObject<T> other_constraints;
+
+ BOOST_MIRROR_CONCEPT_TESTER_END
+
+};
+
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+
Added: sandbox/mirror/boost/mirror/concept/MetaType.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/concept/MetaType.hpp 2008-12-03 11:39:07 EST (Wed, 03 Dec 2008)
@@ -0,0 +1,43 @@
+/**
+ * \file boost/mirror/concept/MetaType.hpp
+ *
+ * Meta function checking whether a given type satisfies the
+ * requirements of the MetaType concept
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under 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)
+ */
+
+#ifndef BOOST_MIRROR_CONCEPT_META_TYPE_HPP
+#define BOOST_MIRROR_CONCEPT_META_TYPE_HPP
+
+#include <boost/mirror/concept/MetaNamedScopedObject.hpp>
+
+namespace boost {
+namespace mirror {
+
+template <typename T>
+struct is_MetaType
+{
+ BOOST_MIRROR_CONCEPT_TESTER_BEGIN
+
+ template <class X>
+ static match test(
+ X*,
+ // check for reflected_type typedef
+ typename X::reflected_type* _x = 0
+ );
+
+ typedef is_MetaNamedScopedObject<T> other_constraints;
+
+ BOOST_MIRROR_CONCEPT_TESTER_END
+
+};
+
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+
Added: sandbox/mirror/boost/mirror/concept/utils.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/concept/utils.hpp 2008-12-03 11:39:07 EST (Wed, 03 Dec 2008)
@@ -0,0 +1,39 @@
+/**
+ * \file boost/mirror/concept/utils.hpp
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under 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)
+ */
+
+#ifndef BOOST_MIRROR_CONCEPT_UTILS_HPP
+#define BOOST_MIRROR_CONCEPT_UTILS_HPP
+
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/and.hpp>
+
+namespace boost {
+namespace mirror {
+
+#define BOOST_MIRROR_CONCEPT_TESTER_BEGIN \
+private: \
+ typedef char mismatch;\
+ struct match { char x,y,z; };\
+ static mismatch test(...);
+
+#define BOOST_MIRROR_CONCEPT_TESTER_END \
+public: \
+ typedef typename ::boost::mpl::and_< \
+ other_constraints, \
+ ::boost::mpl::bool_< \
+ sizeof(match) == \
+ sizeof(test((T*)0)) \
+ > \
+ >::type type;
+
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+
Modified: sandbox/mirror/libs/mirror/test/Jamfile.v2
==============================================================================
--- sandbox/mirror/libs/mirror/test/Jamfile.v2 (original)
+++ sandbox/mirror/libs/mirror/test/Jamfile.v2 2008-12-03 11:39:07 EST (Wed, 03 Dec 2008)
@@ -41,5 +41,8 @@
[ run classes_rt_05.cpp ]
[ run classes_rt_06.cpp ]
[ run classes_rt_07.cpp ]
+ [ compile concepts_ct_01.cpp ]
+ [ compile concepts_ct_02.cpp ]
+ [ compile concepts_ct_03.cpp ]
;
Added: sandbox/mirror/libs/mirror/test/concepts_ct_01.cpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/libs/mirror/test/concepts_ct_01.cpp 2008-12-03 11:39:07 EST (Wed, 03 Dec 2008)
@@ -0,0 +1,67 @@
+/**
+ * \file test/concepts_ct_01.cpp
+ *
+ * This file is part of the Mirror library testsuite.
+ *
+ * Testing type registration and reflection.
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under 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 <boost/mirror/meta_namespace.hpp>
+#include <boost/mirror/meta_namespaces/boost/tuples.hpp>
+#include <boost/mirror/meta_namespaces/boost/fusion.hpp>
+#include <boost/mirror/concept.hpp>
+//
+#include <boost/mpl/accumulate.hpp>
+//
+#include "./namespaces.hpp"
+#include "./test.hpp"
+
+
+template <class X>
+struct test_MetaNamespace
+{
+ typedef typename ::boost::mpl::and_<
+ typename ::boost::mirror::is_MetaNamespace<X>::type,
+ typename ::boost::mirror::is_MetaScope<typename X::scope>::type
+ >::type type;
+};
+
+void test_main()
+{
+ using namespace ::boost;
+ using namespace ::boost::mirror;
+ //
+ // make a list of some meta-namespaces
+ typedef mpl::vector5<
+ BOOST_MIRRORED_NAMESPACE(::std),
+ BOOST_MIRRORED_NAMESPACE(::boost),
+ BOOST_MIRRORED_NAMESPACE(::boost::tuples),
+ BOOST_MIRRORED_NAMESPACE(::boost::fusion),
+ BOOST_MIRRORED_NAMESPACE(::boost::mirror)
+ > some_meta_namespaces;
+ //
+ // test their compliance with the MetaType concept
+ typedef mpl::accumulate<
+ some_meta_namespaces,
+ mpl::true_,
+ mpl::and_<
+ mpl::_1,
+ test_MetaNamespace<mpl::_2>
+ >
+ >::type all_passed;
+ //
+ BOOST_MPL_ASSERT(( all_passed ));
+}
+
+test_suite* init_unit_test_suite( int argc, char* argv[] )
+{
+ test_suite *test = BOOST_TEST_SUITE("Mirror: concept compliance test 01");
+ test->add(BOOST_TEST_CASE(&test_main));
+ return test;
+}
+
+
Added: sandbox/mirror/libs/mirror/test/concepts_ct_02.cpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/libs/mirror/test/concepts_ct_02.cpp 2008-12-03 11:39:07 EST (Wed, 03 Dec 2008)
@@ -0,0 +1,110 @@
+/**
+ * \file test/concepts_ct_02.cpp
+ *
+ * This file is part of the Mirror library testsuite.
+ *
+ * Testing type registration and reflection.
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under 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 <boost/mirror/meta_type.hpp>
+#include <boost/mirror/meta_types/boost/optional.hpp>
+#include <boost/mirror/meta_types/boost/any.hpp>
+#include <boost/mirror/meta_types/boost/variant.hpp>
+#include <boost/mirror/concept.hpp>
+//
+#include <boost/mpl/accumulate.hpp>
+//
+#include "./namespaces.hpp"
+#include "./types.hpp"
+#include "./test.hpp"
+
+
+template <class T>
+struct reflect_type
+{
+ typedef BOOST_MIRRORED_TYPE(T) type;
+};
+
+template <class X>
+struct test_MetaType
+{
+ typedef typename ::boost::mpl::and_<
+ typename ::boost::mirror::is_MetaType<X>::type,
+ typename ::boost::mirror::is_MetaScope<typename X::scope>::type
+ >::type type;
+};
+
+void test_main()
+{
+ using namespace ::boost;
+ using namespace ::boost::mirror;
+ //
+ typedef ::test::feature::detail::foo_impl X;
+ typedef BOOST_MIRROR_TYPEDEF(::test, foobar) Y;
+ typedef BOOST_MIRROR_TYPEDEF(::boost::cts, bstring) W;
+ typedef ::boost::optional< ::boost::any> Z;
+ typedef ::boost::variant< X, Y, W, Z> V;
+ typedef X * const T1;
+ typedef Y volatile * const T2;
+ typedef const volatile W T3;
+ typedef Z const * const T4[][1][2][3][4][5][6][7][8][9];
+ typedef T1& (T5)(T2, T3, T4);
+ typedef T5* (T6)(T5*, T5&, V);
+ typedef T6* T;
+ //
+ // make a list of some types
+ typedef mpl::vector16<
+ void,
+ bool,
+ char,
+ wchar_t,
+ short,
+ int,
+ long,
+ float,
+ double,
+ ::std::string,
+ ::std::wstring,
+ ::boost::cts::bstring,
+ ::test::feature::foo,
+ ::test::bar,
+ baz,
+ T
+ > some_types;
+ //
+ // reflect them using mirror and put them
+ // into a new list
+ typedef mpl::accumulate<
+ some_types,
+ mpl::vector0<>,
+ mpl::push_back<
+ mpl::_1,
+ reflect_type<mpl::_2>
+ >
+ >::type some_meta_types;
+ //
+ // test their compliance with the MetaType concept
+ typedef mpl::accumulate<
+ some_meta_types,
+ mpl::true_,
+ mpl::and_<
+ mpl::_1,
+ test_MetaType<mpl::_2>
+ >
+ >::type all_passed;
+ //
+ BOOST_MPL_ASSERT(( all_passed ));
+}
+
+test_suite* init_unit_test_suite( int argc, char* argv[] )
+{
+ test_suite *test = BOOST_TEST_SUITE("Mirror: concept compliance test 02");
+ test->add(BOOST_TEST_CASE(&test_main));
+ return test;
+}
+
+
Added: sandbox/mirror/libs/mirror/test/concepts_ct_03.cpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/libs/mirror/test/concepts_ct_03.cpp 2008-12-03 11:39:07 EST (Wed, 03 Dec 2008)
@@ -0,0 +1,85 @@
+/**
+ * \file test/concepts_ct_03.cpp
+ *
+ * This file is part of the Mirror library testsuite.
+ *
+ * Testing type registration and reflection.
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under 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 <boost/mirror/meta_class.hpp>
+#include <boost/mirror/meta_classes/std/pair.hpp>
+#include <boost/mirror/meta_classes/boost/tuples/tuple.hpp>
+#include <boost/mirror/concept.hpp>
+//
+#include <boost/mpl/accumulate.hpp>
+//
+#include "./namespaces.hpp"
+#include "./types.hpp"
+#include "./test.hpp"
+
+
+template <class T>
+struct reflect_class
+{
+ typedef BOOST_MIRRORED_CLASS(T) type;
+};
+
+template <class X>
+struct test_MetaClass
+{
+ typedef typename ::boost::mpl::and_<
+ typename ::boost::mirror::is_MetaClass<X>::type,
+ typename ::boost::mirror::is_MetaScope<typename X::scope>::type
+ >::type type;
+};
+
+void test_main()
+{
+ using namespace ::boost;
+ using namespace ::boost::mirror;
+ //
+ typedef ::std::pair< int, ::std::string> T1;
+ typedef ::std::pair< ::std::string, T1> T2;
+ typedef ::std::pair< T1, T2> T3;
+ typedef ::boost::tuple< const T1*, volatile T2*, T3*> T4;
+ // make a list of some classes
+ typedef mpl::vector4<
+ T1, T2, T3, T4
+ > some_classes;
+ //
+ // reflect them using mirror and put them
+ // into a new list
+ typedef mpl::accumulate<
+ some_classes,
+ mpl::vector0<>,
+ mpl::push_back<
+ mpl::_1,
+ reflect_class<mpl::_2>
+ >
+ >::type some_meta_classs;
+ //
+ // test their compliance with the MetaType concept
+ typedef mpl::accumulate<
+ some_meta_classs,
+ mpl::true_,
+ mpl::and_<
+ mpl::_1,
+ test_MetaClass<mpl::_2>
+ >
+ >::type all_passed;
+ //
+ BOOST_MPL_ASSERT(( all_passed ));
+}
+
+test_suite* init_unit_test_suite( int argc, char* argv[] )
+{
+ test_suite *test = BOOST_TEST_SUITE("Mirror: concept compliance test 03");
+ test->add(BOOST_TEST_CASE(&test_main));
+ return test;
+}
+
+
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk