|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r62255 - in trunk: boost/proto/detail libs/proto/test
From: eric_at_[hidden]
Date: 2010-05-26 22:39:11
Author: eric_niebler
Date: 2010-05-26 22:39:10 EDT (Wed, 26 May 2010)
New Revision: 62255
URL: http://svn.boost.org/trac/boost/changeset/62255
Log:
add test for internal domain deduction utilities
Added:
trunk/libs/proto/test/deduce_domain.cpp (contents, props changed)
Text files modified:
trunk/boost/proto/detail/deduce_domain.hpp | 6 +++++-
trunk/libs/proto/test/Jamfile.v2 | 1 +
2 files changed, 6 insertions(+), 1 deletions(-)
Modified: trunk/boost/proto/detail/deduce_domain.hpp
==============================================================================
--- trunk/boost/proto/detail/deduce_domain.hpp (original)
+++ trunk/boost/proto/detail/deduce_domain.hpp 2010-05-26 22:39:10 EDT (Wed, 26 May 2010)
@@ -27,6 +27,10 @@
#include <boost/type_traits/is_same.hpp>
#include <boost/proto/proto_fwd.hpp>
+#ifndef BOOST_PROTO_ASSERT_VALID_DOMAIN
+# define BOOST_PROTO_ASSERT_VALID_DOMAIN(DOM) BOOST_MPL_ASSERT_NOT((boost::is_same<DOM, boost::proto::detail::not_a_domain>))
+#endif
+
namespace boost
{
namespace proto
@@ -171,7 +175,7 @@
typedef A0 common1; \
BOOST_PP_REPEAT_FROM_TO(1, N, M0, ~) \
typedef common ## N type; \
- BOOST_MPL_ASSERT_NOT((is_same<type, not_a_domain>)); \
+ BOOST_PROTO_ASSERT_VALID_DOMAIN(type); \
}; \
\
template<BOOST_PP_ENUM_PARAMS(N, typename E)> \
Modified: trunk/libs/proto/test/Jamfile.v2
==============================================================================
--- trunk/libs/proto/test/Jamfile.v2 (original)
+++ trunk/libs/proto/test/Jamfile.v2 2010-05-26 22:39:10 EDT (Wed, 26 May 2010)
@@ -21,6 +21,7 @@
:
[ run calculator.cpp ]
[ run deep_copy.cpp ]
+ [ run deduce_domain.cpp ]
[ run examples.cpp ]
[ run lambda.cpp ]
[ run make_expr.cpp ]
Added: trunk/libs/proto/test/deduce_domain.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/proto/test/deduce_domain.cpp 2010-05-26 22:39:10 EDT (Wed, 26 May 2010)
@@ -0,0 +1,141 @@
+///////////////////////////////////////////////////////////////////////////////
+// deduce_domain.hpp
+//
+// Copyright 2008 Eric Niebler. 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)
+
+// Avoid a compile-time check inside the deduce_domain code.
+#define BOOST_PROTO_ASSERT_VALID_DOMAIN(DOM) typedef DOM DOM ## _
+
+#include <boost/proto/core.hpp>
+#include <boost/test/unit_test.hpp>
+#include <boost/mpl/assert.hpp>
+#include <boost/type_traits/is_same.hpp>
+
+using namespace boost::proto;
+
+struct D0 : domain<>
+{
+};
+
+struct D1 : domain<default_generator, _, D0>
+{
+};
+
+struct D2 : domain<default_generator, _, D0>
+{
+};
+
+struct D3 : domain<>
+{
+};
+
+struct DD0 : domain<default_generator, _, default_domain>
+{
+};
+
+struct DD1 : domain<default_generator, _, default_domain>
+{
+};
+
+struct DD2 : domain<default_generator, _, default_domain>
+{
+};
+
+struct DD3 : domain<default_generator, _, DD2>
+{
+};
+
+struct DD4 : domain<default_generator, _, DD2>
+{
+};
+
+void test1()
+{
+ using boost::is_same;
+
+ //*
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<D0, D0, D0>::type, D0>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<default_domain, D0, D0>::type, D0>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<D0, default_domain, D0>::type, D0>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<D0, D0, default_domain>::type, D0>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<D0, default_domain, default_domain>::type, D0>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<default_domain, D0, default_domain>::type, D0>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<default_domain, default_domain, D0>::type, D0>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<default_domain, default_domain, default_domain>::type, default_domain>));
+
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<DD0, D0, D0>::type, D0>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<D0, DD0, D0>::type, D0>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<D0, D0, DD0>::type, D0>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<D0, DD0, DD0>::type, D0>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<DD0, D0, DD0>::type, D0>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<DD0, DD0, D0>::type, D0>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<default_domain, DD0, DD0>::type, DD0>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<DD0, default_domain, DD0>::type, DD0>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<DD0, DD0, default_domain>::type, DD0>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<default_domain, default_domain, DD0>::type, DD0>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<default_domain, DD0, default_domain>::type, DD0>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<DD0, DD0, default_domain>::type, DD0>));
+
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<D0, D0, D1>::type, D0>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<D0, D1, D0>::type, D0>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<D0, D1, D1>::type, D0>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<D1, D0, D0>::type, D0>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<D1, D0, D1>::type, D0>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<D1, D1, D0>::type, D0>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<D1, D1, D1>::type, D1>));
+
+ // Very tricky to get right
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<D2, D2, D1>::type, D0>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<D2, D1, D2>::type, D0>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<D2, D1, D1>::type, D0>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<D1, D2, D2>::type, D0>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<D1, D2, D1>::type, D0>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<D1, D1, D2>::type, D0>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<D1, D1, D1>::type, D1>));
+
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<D3, D0, D0>::type, detail::not_a_domain>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<D0, D3, D0>::type, detail::not_a_domain>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<D0, D0, D3>::type, detail::not_a_domain>));
+
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<D3, D1, D0>::type, detail::not_a_domain>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<D3, D0, D1>::type, detail::not_a_domain>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<D1, D3, D0>::type, detail::not_a_domain>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<D0, D3, D1>::type, detail::not_a_domain>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<D0, D1, D3>::type, detail::not_a_domain>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<D1, D0, D3>::type, detail::not_a_domain>));
+
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<D3, D1, D2>::type, detail::not_a_domain>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<D3, D2, D1>::type, detail::not_a_domain>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<D1, D3, D2>::type, detail::not_a_domain>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<D2, D3, D1>::type, detail::not_a_domain>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<D2, D1, D3>::type, detail::not_a_domain>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<D1, D2, D3>::type, detail::not_a_domain>));
+
+ // These should be ambiguous.
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<DD1, DD0, DD0>::type, detail::not_a_domain>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<DD0, DD1, DD0>::type, detail::not_a_domain>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<DD0, DD0, DD1>::type, detail::not_a_domain>));
+
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<DD3, DD2, DD2>::type, DD2>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<DD2, DD3, DD2>::type, DD2>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<DD2, DD2, DD3>::type, DD2>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<DD3, DD4, DD4>::type, DD2>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<DD4, DD3, DD4>::type, DD2>));
+ BOOST_MPL_ASSERT((is_same<detail::common_domain3<DD4, DD4, DD3>::type, DD2>));
+ //*/
+}
+
+using namespace boost::unit_test;
+///////////////////////////////////////////////////////////////////////////////
+// init_unit_test_suite
+//
+test_suite* init_unit_test_suite( int argc, char* argv[] )
+{
+ test_suite *test = BOOST_TEST_SUITE("test deducing domains from sub-domains");
+
+ test->add(BOOST_TEST_CASE(&test1));
+
+ 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