Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r73843 - in sandbox/variadic_macro_data: boost/variadic_macro_data/detail libs/variadic_macro_data/doc libs/variadic_macro_data/test
From: eldiener_at_[hidden]
Date: 2011-08-17 11:03:15


Author: eldiener
Date: 2011-08-17 11:03:12 EDT (Wed, 17 Aug 2011)
New Revision: 73843
URL: http://svn.boost.org/trac/boost/changeset/73843

Log:
Updated tests.
Text files modified:
   sandbox/variadic_macro_data/boost/variadic_macro_data/detail/vmd_detail_setup.hpp | 7 ++---
   sandbox/variadic_macro_data/libs/variadic_macro_data/doc/vmd_detail.qbk | 19 ++++++++++++++--
   sandbox/variadic_macro_data/libs/variadic_macro_data/test/Jamfile.v2 | 44 ++++++++++++++++++++++++++++++++++++++++
   sandbox/variadic_macro_data/libs/variadic_macro_data/test/test_is_empty.cpp | 25 ++++++++++++++++++++--
   4 files changed, 85 insertions(+), 10 deletions(-)

Modified: sandbox/variadic_macro_data/boost/variadic_macro_data/detail/vmd_detail_setup.hpp
==============================================================================
--- sandbox/variadic_macro_data/boost/variadic_macro_data/detail/vmd_detail_setup.hpp (original)
+++ sandbox/variadic_macro_data/boost/variadic_macro_data/detail/vmd_detail_setup.hpp 2011-08-17 11:03:12 EDT (Wed, 17 Aug 2011)
@@ -11,13 +11,11 @@
 #define BOOST_VMD_VARIADICS BOOST_PP_VARIADICS
 #if BOOST_VMD_VARIADICS
 #define BOOST_VMD_MSVC BOOST_PP_VARIADICS_MSVC
-#if BOOST_VMD_MSVC
-#if defined(_MSC_VER) && _MSC_VER == 1400
+#if BOOST_VMD_MSVC && defined(_MSC_VER) && _MSC_VER == 1400
 #define BOOST_VMD_MSVC_V8 1
 #else
 #define BOOST_VMD_MSVC_V8 0
-#endif /* _MSC_VER */
-#endif /* BOOST_VMD_MSVC */
+#endif /* BOOST_VMD_MSVC && defined(_MSC_VER) && _MSC_VER == 1400 */
 #endif /* BOOST_VMD_VARIADICS */
 #endif /* BOOST_PP_VARIADICS */
 #endif /* BOOST_VMD_VARIADICS && BOOST_VMD_PPLIB */
@@ -35,6 +33,7 @@
 #endif /* _MSC_VER */
 #else
 #define BOOST_VMD_MSVC 0
+#define BOOST_VMD_MSVC_V8 0
 #endif /* BOOST_MSVC */
 #if !defined(BOOST_VMD_ASSERT_DATA)
 #if defined(NDEBUG)

Modified: sandbox/variadic_macro_data/libs/variadic_macro_data/doc/vmd_detail.qbk
==============================================================================
--- sandbox/variadic_macro_data/libs/variadic_macro_data/doc/vmd_detail.qbk (original)
+++ sandbox/variadic_macro_data/libs/variadic_macro_data/doc/vmd_detail.qbk 2011-08-17 11:03:12 EDT (Wed, 17 Aug 2011)
@@ -423,9 +423,22 @@
 input is a function-like macro name. Here are the problems that can occur
 in this case:
 
-# If the function-like macro has one or more parameters: a compiler error should occur.
-# If the function-like macro has no parameters but outputs a Boost PP tuple with one or more elements: a compiler error should occur.
-# If the function-like macro has no parameters but outputs a set of empty parameters when using VC++: an incorrect result will occur. This is because of a bug in the VC++ preprocessor.
+# If the function-like macro has two or more parameters: a compiler error should occur.
+# If the function-like macro has less than two parameters but outputs a Boost PP tuple (parens with one or more elements): a compiler error should occur.
+
+For the Visual C++ compiler the above is not the case,
+and instead of putting out a compiler error, the Visual C++ compiler
+only issues warnings. Furthermore the Visual C++ compiler will give the
+incorrect result whenever the function-like macro name produces a Boost PP tuple
+or an empty set of parens, treating the input as empty. I have not been able to
+find a workaround for the behavior of Visual C++ in the above respect.
+
+With all of the above mentioned, the case(s) where BOOST_VMD_IS_EMPTY work
+incorrectly are very small, and I considered the macro worthwhile to use
+with the vast majority of possible input. The macro is used extensiovely in the
+assert-like macros explained further on in the documentation and macro programmers
+may find this macro useful in their own programming efforts despite the slight
+flaw in the way that it works.
 
 The end-user of VMD can include the individual header file 'vmd_is_empty.hpp'
 instead of the general header file 'vmd.hpp' for using this macro.

Modified: sandbox/variadic_macro_data/libs/variadic_macro_data/test/Jamfile.v2
==============================================================================
--- sandbox/variadic_macro_data/libs/variadic_macro_data/test/Jamfile.v2 (original)
+++ sandbox/variadic_macro_data/libs/variadic_macro_data/test/Jamfile.v2 2011-08-17 11:03:12 EDT (Wed, 17 Aug 2011)
@@ -34,6 +34,10 @@
         [ run test_is_begin_parens.cpp ]
         [ run test_remove_parens.cpp ]
         [ run test_is_empty.cpp ]
+ [ compile-fail test_is_empty_fail.cpp ]
+ [ compile-fail test_is_empty_fail2.cpp ]
+ [ compile-fail test_is_empty_fail3.cpp ]
+ [ compile-fail test_is_empty_fail4.cpp ]
         [ compile test_assert_is_tuple.cpp :
           <define>BOOST_VMD_ASSERT_DATA=1 ]
         [ compile-fail test_assert_is_tuple_fail.cpp :
@@ -102,6 +106,18 @@
         [ run test_is_empty.cpp : : :
           <define>BOOST_VMD_TEST_GENERAL_HEADER :
           test_is_empty_gh ]
+ [ compile-fail test_is_empty_fail.cpp :
+ <define>BOOST_VMD_TEST_GENERAL_HEADER :
+ test_is_empty_fail_gh ]
+ [ compile-fail test_is_empty_fail2.cpp :
+ <define>BOOST_VMD_TEST_GENERAL_HEADER :
+ test_is_empty_fail2_gh ]
+ [ compile-fail test_is_empty_fail3.cpp :
+ <define>BOOST_VMD_TEST_GENERAL_HEADER :
+ test_is_empty_fail3_gh ]
+ [ compile-fail test_is_empty_fail4.cpp :
+ <define>BOOST_VMD_TEST_GENERAL_HEADER :
+ test_is_empty_fail4_gh ]
         [ compile test_assert_is_tuple.cpp :
           <define>BOOST_VMD_ASSERT_DATA=1
           <define>BOOST_VMD_TEST_GENERAL_HEADER :
@@ -210,6 +226,18 @@
         [ run test_is_empty.cpp : : :
           <define>BOOST_VMD_PPLIB=1 :
           test_is_empty_pplib ]
+ [ compile-fail test_is_empty_fail.cpp :
+ <define>BOOST_VMD_PPLIB=1 :
+ test_is_empty_fail_pplib ]
+ [ compile-fail test_is_empty_fail2.cpp :
+ <define>BOOST_VMD_PPLIB=1 :
+ test_is_empty_fail2_pplib ]
+ [ compile-fail test_is_empty_fail3.cpp :
+ <define>BOOST_VMD_PPLIB=1 :
+ test_is_empty_fail3_pplib ]
+ [ compile-fail test_is_empty_fail4.cpp :
+ <define>BOOST_VMD_PPLIB=1 :
+ test_is_empty_fail4_pplib ]
         [ compile test_assert_is_tuple.cpp :
           <define>BOOST_VMD_ASSERT_DATA=1
           <define>BOOST_VMD_PPLIB=1 :
@@ -326,6 +354,22 @@
           <define>BOOST_VMD_TEST_GENERAL_HEADER
           <define>BOOST_VMD_PPLIB=1 :
           test_is_empty_ppgh ]
+ [ compile-fail test_is_empty_fail.cpp :
+ <define>BOOST_VMD_TEST_GENERAL_HEADER
+ <define>BOOST_VMD_PPLIB=1 :
+ test_is_empty_fail_ppgh ]
+ [ compile-fail test_is_empty_fail2.cpp :
+ <define>BOOST_VMD_TEST_GENERAL_HEADER
+ <define>BOOST_VMD_PPLIB=1 :
+ test_is_empty_fail2_ppgh ]
+ [ compile-fail test_is_empty_fail3.cpp :
+ <define>BOOST_VMD_TEST_GENERAL_HEADER
+ <define>BOOST_VMD_PPLIB=1 :
+ test_is_empty_fail3_ppgh ]
+ [ compile-fail test_is_empty_fail4.cpp :
+ <define>BOOST_VMD_TEST_GENERAL_HEADER
+ <define>BOOST_VMD_PPLIB=1 :
+ test_is_empty_fail4_ppgh ]
         [ compile test_assert_is_tuple.cpp :
           <define>BOOST_VMD_TEST_GENERAL_HEADER
           <define>BOOST_VMD_ASSERT_DATA=1

Modified: sandbox/variadic_macro_data/libs/variadic_macro_data/test/test_is_empty.cpp
==============================================================================
--- sandbox/variadic_macro_data/libs/variadic_macro_data/test/test_is_empty.cpp (original)
+++ sandbox/variadic_macro_data/libs/variadic_macro_data/test/test_is_empty.cpp 2011-08-17 11:03:12 EDT (Wed, 17 Aug 2011)
@@ -16,7 +16,6 @@
   #define OBJECT2
   #define FUNC(x) FUNC2(x)
   #define FUNC2(x)
- #define FUNC_GEN() ()
   
   BOOST_TEST(BOOST_VMD_IS_EMPTY(BOOST_PP_EMPTY()));
   BOOST_TEST(BOOST_VMD_IS_EMPTY(DATA BOOST_PP_EMPTY()));
@@ -24,18 +23,38 @@
   BOOST_TEST(BOOST_VMD_IS_EMPTY(OBJECT BOOST_PP_EMPTY()));
   BOOST_TEST(BOOST_VMD_IS_EMPTY(FUNC(z) BOOST_PP_EMPTY()));
   
+ #define FUNC_GEN() ()
+ #define FUNC_GEN2(x) ()
+ #define FUNC_GEN3() anything
+ #define FUNC_GEN4(x) anything
+
 #if BOOST_VMD_MSVC
 
- /* This shows that VC++ does not work correctly in this case. */
+ #define FUNC_GEN5(x,y) anything
+ #define FUNC_GEN6() (&)
+ #define FUNC_GEN7(x) (y)
+ #define FUNC_GEN8() (y,z)
+
+ /* This shows that VC++ does not work correctly in these cases. */
 
- BOOST_TEST(BOOST_VMD_IS_EMPTY(FUNC_GEN));
+ BOOST_TEST(BOOST_VMD_IS_EMPTY(FUNC_GEN)); /* This produces the wrong result */
+ BOOST_TEST(BOOST_VMD_IS_EMPTY(FUNC_GEN2)); /* This produces the wrong result */
+
+ BOOST_TEST(!BOOST_VMD_IS_EMPTY(FUNC_GEN5)); /* This should produce a compiler error but does not */
+ BOOST_TEST(BOOST_VMD_IS_EMPTY(FUNC_GEN6)); /* This produces the wrong results and also should produce a compiler error but does not */
+ BOOST_TEST(BOOST_VMD_IS_EMPTY(FUNC_GEN7)); /* This produces the wrong results and also should produce a compiler error but does not */
+ BOOST_TEST(BOOST_VMD_IS_EMPTY(FUNC_GEN8)); /* This produces the wrong results and also should produce a compiler error but does not */
 
 #else
 
   BOOST_TEST(!BOOST_VMD_IS_EMPTY(FUNC_GEN));
+ BOOST_TEST(!BOOST_VMD_IS_EMPTY(FUNC_GEN2));
   
 #endif /* BOOST_VMD_MSVC */
 
+ BOOST_TEST(!BOOST_VMD_IS_EMPTY(FUNC_GEN3));
+ BOOST_TEST(!BOOST_VMD_IS_EMPTY(FUNC_GEN4));
+
 #endif /* BOOST_VMD_VARIADICS */
 
   return boost::report_errors();


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