Addition of is_empty tests and changes to rem processing as a workaround to VC++ problem.

This commit is contained in:
Edward Diener
2014-04-30 16:06:49 -04:00
parent 6fe93a542d
commit c66ea5871f
24 changed files with 476 additions and 66 deletions

View File

@ -19,23 +19,22 @@ project preprocessor_tests : requirements <warnings>on
test-suite preprocessor
:
[ compile arithmetic.cpp ]
[ compile array.cpp ]
[ compile comparison.cpp ]
[ compile control.cpp ]
[ compile debug.cpp ]
[ compile facilities.cpp ]
[ compile isempty.cpp ]
[ compile iteration.cpp ]
[ compile list.cpp ]
[ compile logical.cpp ]
[ compile punctuation.cpp ]
[ compile repetition.cpp ]
[ compile selection.cpp ]
[ compile seq.cpp ]
[ compile slot.cpp ]
[ compile tuple.cpp ]
[ compile variadic.cpp ]
[ compile arithmetic.cpp : <toolset>gcc:<cxxflags>-std=c++0x ]
[ compile array.cpp : <toolset>gcc:<cxxflags>-std=c++0x ]
[ compile comparison.cpp : <toolset>gcc:<cxxflags>-std=c++0x ]
[ compile control.cpp : <toolset>gcc:<cxxflags>-std=c++0x ]
[ compile debug.cpp : <toolset>gcc:<cxxflags>-std=c++0x ]
[ compile facilities.cpp : <toolset>gcc:<cxxflags>-std=c++0x ]
[ compile iteration.cpp : <toolset>gcc:<cxxflags>-std=c++0x ]
[ compile list.cpp : <toolset>gcc:<cxxflags>-std=c++0x ]
[ compile logical.cpp : <toolset>gcc:<cxxflags>-std=c++0x ]
[ compile punctuation.cpp : <toolset>gcc:<cxxflags>-std=c++0x ]
[ compile repetition.cpp : <toolset>gcc:<cxxflags>-std=c++0x ]
[ compile selection.cpp : <toolset>gcc:<cxxflags>-std=c++0x ]
[ compile seq.cpp : <toolset>gcc:<cxxflags>-std=c++0x ]
[ compile slot.cpp : <toolset>gcc:<cxxflags>-std=c++0x ]
[ compile tuple.cpp : <toolset>gcc:<cxxflags>-std=c++0x ]
[ compile variadic.cpp : <toolset>gcc:<cxxflags>-std=c++0x ]
;
test-suite preprocessor_nvm
@ -46,7 +45,6 @@ test-suite preprocessor_nvm
[ compile control.cpp : <define>BOOST_PP_VARIADICS=0 : control_nvm ]
[ compile debug.cpp : <define>BOOST_PP_VARIADICS=0 : debug_nvm ]
[ compile facilities.cpp : <define>BOOST_PP_VARIADICS=0 : facilities_nvm ]
[ compile isempty.cpp : <define>BOOST_PP_VARIADICS=0 : isempty_nvm ]
[ compile iteration.cpp : <define>BOOST_PP_VARIADICS=0 : iteration_nvm ]
[ compile list.cpp : <define>BOOST_PP_VARIADICS=0 : list_nvm ]
[ compile logical.cpp : <define>BOOST_PP_VARIADICS=0 : logical_nvm ]
@ -83,10 +81,6 @@ test-suite preprocessor_c
: <toolset>gcc:<cflags>-std=c99
: facilities_c
]
[ compile isempty.c
: <toolset>gcc:<cflags>-std=c99
: isempty_c
]
[ compile list.c
: <toolset>gcc:<cflags>-std=c99
: list_c
@ -153,11 +147,6 @@ test-suite preprocessor_c_nvm
<toolset>gcc:<cflags>-std=c99
: facilities_c_nvm
]
[ compile isempty.c
: <define>BOOST_PP_VARIADICS=0
<toolset>gcc:<cflags>-std=c99
: isempty_c_nvm
]
[ compile list.c
: <define>BOOST_PP_VARIADICS=0
<toolset>gcc:<cflags>-std=c99
@ -189,3 +178,52 @@ test-suite preprocessor_c_nvm
: tuple_c_nvm
]
;
# test-suite preprocessor_isempty
# :
# [ compile isempty.cpp : <toolset>gcc:<cxxflags>-std=c++0x ]
# [ compile-fail isempty_variadic_standard_failure.cpp : <toolset>gcc:<cxxflags>-std=c++0x ]
# [ compile-fail isempty_variadic_standard_failure2.cpp : <toolset>gcc:<cxxflags>-std=c++0x ]
# ;
test-suite preprocessor_isempty_nvm
:
[ compile isempty.cpp : <define>BOOST_PP_VARIADICS=0 : isempty_nvm ]
[ compile-fail isempty_failure.cpp : <define>BOOST_PP_VARIADICS=0 : isempty_failure_nvm ]
[ compile-fail isempty_failure2.cpp : <define>BOOST_PP_VARIADICS=0 : isempty_failure2_nvm ]
;
# test-suite preprocessor_isempty_c
# :
# [ compile isempty.c
# : <toolset>gcc:<cflags>-std=c99
# : isempty_c
# ]
# [ compile-fail isempty_variadic_standard_failure.c
# : <toolset>gcc:<cflags>-std=c99
# : isempty_variadic_standard_failure_c
# ]
# [ compile-fail isempty_variadic_standard_failure2.c
# : <toolset>gcc:<cflags>-std=c99
# : isempty_variadic_standard_failure2_c
# ]
# ;
test-suite preprocessor_isempty_c_nvm
:
[ compile isempty.c
: <define>BOOST_PP_VARIADICS=0
<toolset>gcc:<cflags>-std=c99
: isempty_c_nvm
]
[ compile-fail isempty_failure.c
: <define>BOOST_PP_VARIADICS=0
<toolset>gcc:<cflags>-std=c99
: isempty_failure_c_nvm
]
[ compile-fail isempty_failure2.c
: <define>BOOST_PP_VARIADICS=0
<toolset>gcc:<cflags>-std=c99
: isempty_failure2_c_nvm
]
;

View File

@ -1,6 +1,6 @@
# /* **************************************************************************
# * *
# * (C) Copyright Paul Mensonides 2002.
# * (C) Copyright Edward Diener 2014.
# * 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)

View File

@ -11,12 +11,8 @@
#
# include <boost/preprocessor/facilities/empty.hpp>
# include <boost/preprocessor/facilities/is_empty.hpp>
# include <boost/preprocessor/facilities/is_empty_or_1.hpp>
# include <boost/preprocessor/facilities/is_1.hpp>
# include <libs/preprocessor/test/test.h>
#if BOOST_PP_VARIADICS
#define DATA
#define OBJECT OBJECT2
#define OBJECT2
@ -29,38 +25,53 @@
#define FUNC_GEN5() (y,z)
#define FUNC_GEN6() anything
#define FUNC_GEN7(x) anything
#if defined(BOOST_PP_VARIADICS_MSVC)
#define FUNC_GEN8(x,y) (1,2,3)
#define FUNC_GEN9(x,y,z) anything
/* These next five produce the wrong result in VC++ */
#define FUNC_GEN10(x) (y) data
#define NAME &name
#define ATUPLE (atuple)
#define ATUPLE_PLUS (atuple) data
#if BOOST_PP_VARIADICS
#if defined(BOOST_PP_VARIADICS_MSVC) /* Testing the VC++ variadic version */
/* INCORRECT */
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN) == 1 END
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN2) == 1 END
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN3) == 1 END
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN4) == 1 END
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN5) == 1 END
/* This next should produce a compiler error but does not, and produces the incorrect result */
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN8) == 1 END
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN10) == 1 END
/* This next should produce a compiler error but does not */
/* CORRECT */
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN9) == 0 END
#else
#else /* Testing the non-VC++ variadic version */
/* CORRECT */
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN) == 0 END
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN2) == 0 END
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN3) == 0 END
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN4) == 0 END
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN5) == 0 END
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN10) == 0 END
/* COMPILER ERROR */
// BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN8) == 0 END
// BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN9) == 0 END
#endif
/* Testing the variadic version */
/* CORRECT */
BEGIN BOOST_PP_IS_EMPTY(BOOST_PP_EMPTY()) == 1 END
BEGIN BOOST_PP_IS_EMPTY(DATA BOOST_PP_EMPTY()) == 1 END
BEGIN BOOST_PP_IS_EMPTY(x BOOST_PP_EMPTY()) == 0 END
@ -68,5 +79,61 @@ BEGIN BOOST_PP_IS_EMPTY(OBJECT BOOST_PP_EMPTY()) == 1 END
BEGIN BOOST_PP_IS_EMPTY(FUNC(z) BOOST_PP_EMPTY()) == 1 END
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN6) == 0 END
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN7) == 0 END
BEGIN BOOST_PP_IS_EMPTY(NAME) == 0 END
BEGIN BOOST_PP_IS_EMPTY(ATUPLE) == 0 END
BEGIN BOOST_PP_IS_EMPTY(ATUPLE_PLUS) == 0 END
#else
#if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC() /* Testing the VC++ non-variadic version */
/* INCORRECT */
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN) == 1 END
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN2) == 1 END
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN3) == 1 END
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN4) == 1 END
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN5) == 1 END
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN8) == 1 END
BEGIN BOOST_PP_IS_EMPTY(ATUPLE) == 1 END
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN10) == 1 END
BEGIN BOOST_PP_IS_EMPTY(ATUPLE_PLUS) == 1 END
/* CORRECT */
BEGIN BOOST_PP_IS_EMPTY(NAME) == 0 END
#else /* Testing the non-VC++ non-variadic version */
/* CORRECT */
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN) == 0 END
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN2) == 0 END
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN3) == 0 END
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN4) == 0 END
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN5) == 0 END
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN8) == 0 END
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN10) == 0 END
/* COMPILER ERROR */
// BEGIN BOOST_PP_IS_EMPTY(ATUPLE) == 0 END
// BEGIN BOOST_PP_IS_EMPTY(ATUPLE_PLUS) == 1 END
// BEGIN BOOST_PP_IS_EMPTY(NAME) == 0 END
#endif
/* Testing the non-variadic version */
/* CORRECT */
BEGIN BOOST_PP_IS_EMPTY(BOOST_PP_EMPTY()) == 1 END
BEGIN BOOST_PP_IS_EMPTY(DATA BOOST_PP_EMPTY()) == 1 END
BEGIN BOOST_PP_IS_EMPTY(x BOOST_PP_EMPTY()) == 0 END
BEGIN BOOST_PP_IS_EMPTY(OBJECT BOOST_PP_EMPTY()) == 1 END
BEGIN BOOST_PP_IS_EMPTY(FUNC(z) BOOST_PP_EMPTY()) == 1 END
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN6) == 0 END
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN7) == 0 END
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN9) == 0 END
#endif

12
test/isempty_failure.c Normal file
View File

@ -0,0 +1,12 @@
# /* **************************************************************************
# * *
# * (C) Copyright Edward Diener 2014.
# * 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)
# * *
# ************************************************************************** */
#
# /* See http://www.boost.org for most recent version. */
#
# include <libs/preprocessor/test/isempty_failure.cxx>

12
test/isempty_failure.cpp Normal file
View File

@ -0,0 +1,12 @@
# /* **************************************************************************
# * *
# * (C) Copyright Edward Diener 2014.
# * 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)
# * *
# ************************************************************************** */
#
# /* See http://www.boost.org for most recent version. */
#
# include <libs/preprocessor/test/isempty_failure.cxx>

25
test/isempty_failure.cxx Normal file
View File

@ -0,0 +1,25 @@
# /* **************************************************************************
# * *
# * (C) Copyright Edward Diener 2014.
# * 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)
# * *
# ************************************************************************** */
#
# /* See http://www.boost.org for most recent version. */
#
# include <boost/preprocessor/facilities/is_empty.hpp>
# include <libs/preprocessor/test/test.h>
#if !BOOST_PP_VARIADICS && (~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC()) && (~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC())
#define NAME &name
BEGIN BOOST_PP_IS_EMPTY(NAME) == 0 END
#else
BEGIN 1 == 0 END
#endif

12
test/isempty_failure2.c Normal file
View File

@ -0,0 +1,12 @@
# /* **************************************************************************
# * *
# * (C) Copyright Edward Diener 2014.
# * 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)
# * *
# ************************************************************************** */
#
# /* See http://www.boost.org for most recent version. */
#
# include <libs/preprocessor/test/isempty_failure2.cxx>

12
test/isempty_failure2.cpp Normal file
View File

@ -0,0 +1,12 @@
# /* **************************************************************************
# * *
# * (C) Copyright Edward Diener 2014.
# * 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)
# * *
# ************************************************************************** */
#
# /* See http://www.boost.org for most recent version. */
#
# include <libs/preprocessor/test/isempty_failure2.cxx>

25
test/isempty_failure2.cxx Normal file
View File

@ -0,0 +1,25 @@
# /* **************************************************************************
# * *
# * (C) Copyright Edward Diener 2014.
# * 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)
# * *
# ************************************************************************** */
#
# /* See http://www.boost.org for most recent version. */
#
# include <boost/preprocessor/facilities/is_empty.hpp>
# include <libs/preprocessor/test/test.h>
#if !BOOST_PP_VARIADICS && (~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC()) && (~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC())
#define ATUPLE_PLUS (atuple) data
BEGIN BOOST_PP_IS_EMPTY(ATUPLE_PLUS) == 0 END
#else
BEGIN 1 == 0 END
#endif

View File

@ -0,0 +1,12 @@
# /* **************************************************************************
# * *
# * (C) Copyright Edward Diener 2014.
# * 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)
# * *
# ************************************************************************** */
#
# /* See http://www.boost.org for most recent version. */
#
# include <libs/preprocessor/test/isempty_variadic_standard_failure.cxx>

View File

@ -0,0 +1,12 @@
# /* **************************************************************************
# * *
# * (C) Copyright Edward Diener 2014.
# * 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)
# * *
# ************************************************************************** */
#
# /* See http://www.boost.org for most recent version. */
#
# include <libs/preprocessor/test/isempty_variadic_standard_failure.cxx>

View File

@ -0,0 +1,25 @@
# /* **************************************************************************
# * *
# * (C) Copyright Edward Diener 2014.
# * 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)
# * *
# ************************************************************************** */
#
# /* See http://www.boost.org for most recent version. */
#
# include <boost/preprocessor/facilities/is_empty.hpp>
# include <libs/preprocessor/test/test.h>
#if BOOST_PP_VARIADICS && !defined(BOOST_PP_VARIADICS_MSVC)
#define FUNC_GEN8(x,y) (1,2,3)
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN8) == 0 END
#else
BEGIN 1 == 0 END
#endif

View File

@ -0,0 +1,12 @@
# /* **************************************************************************
# * *
# * (C) Copyright Edward Diener 2014.
# * 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)
# * *
# ************************************************************************** */
#
# /* See http://www.boost.org for most recent version. */
#
# include <libs/preprocessor/test/isempty_variadic_standard_failure2.cxx>

View File

@ -0,0 +1,12 @@
# /* **************************************************************************
# * *
# * (C) Copyright Edward Diener 2014.
# * 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)
# * *
# ************************************************************************** */
#
# /* See http://www.boost.org for most recent version. */
#
# include <libs/preprocessor/test/isempty_variadic_standard_failure2.cxx>

View File

@ -0,0 +1,25 @@
# /* **************************************************************************
# * *
# * (C) Copyright Edward Diener 2014.
# * 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)
# * *
# ************************************************************************** */
#
# /* See http://www.boost.org for most recent version. */
#
# include <boost/preprocessor/facilities/is_empty.hpp>
# include <libs/preprocessor/test/test.h>
#if BOOST_PP_VARIADICS && !defined(BOOST_PP_VARIADICS_MSVC)
#define FUNC_GEN9(x,y,z) anything
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN9) == 0 END
#else
BEGIN 1 == 0 END
#endif

View File

@ -7,10 +7,12 @@
# * *
# ************************************************************************** */
#
# /* Revised by Edward Diener (2011) */
# /* Revised by Edward Diener (2011,2014) */
#
# /* See http://www.boost.org for most recent version. */
#
# include <boost/preprocessor/cat.hpp>
# include <boost/preprocessor/control/if.hpp>
# include <boost/preprocessor/tuple.hpp>
# include <boost/preprocessor/array/elem.hpp>
# include <boost/preprocessor/list/at.hpp>
@ -20,6 +22,7 @@
# include <boost/preprocessor/variadic/elem.hpp>
# endif
# include <libs/preprocessor/test/test.h>
# include <libs/preprocessor/test/tuple_elem_bug_test.cxx>
# define TUPLE (0, 1, 2, 3, 4, 5)
# define TUPLE_LARGE (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32)

View File

@ -0,0 +1,38 @@
# /* **************************************************************************
# * *
# * (C) Copyright Edward Diener 2014.
# * 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)
# * *
# ************************************************************************** */
#
# /* See http://www.boost.org for most recent version. */
#
# include <boost/preprocessor/cat.hpp>
# include <boost/preprocessor/control/if.hpp>
# include <boost/preprocessor/tuple.hpp>
# include <libs/preprocessor/test/test.h>
#define TN_GEN_ONE(p) (1)
#define TN_GEN_ZERO(p) (0)
#define TN_TEST_ONE_MORE(parameter,ens) \
BOOST_PP_IF \
( \
BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(1,0,ens),0), \
TN_GEN_ONE, \
TN_GEN_ZERO \
) \
(parameter) \
/**/
#define TN_TEST_ONE(parameter,ens) \
BOOST_PP_TUPLE_ELEM \
( \
1, \
0, \
TN_TEST_ONE_MORE(parameter,ens) \
) \
/**/
BEGIN TN_TEST_ONE(A,(1)) == 1 END
BEGIN TN_TEST_ONE(A,()) == 0 END