Boost logo

Boost-Commit :

From: eric_at_[hidden]
Date: 2007-10-10 14:13:19


Author: eric_niebler
Date: 2007-10-10 14:13:18 EDT (Wed, 10 Oct 2007)
New Revision: 39897
URL: http://svn.boost.org/trac/boost/changeset/39897

Log:
work around gcc bug in proto, add test for custom assertions, fix more gcc warnings
Added:
   trunk/libs/xpressive/test/test_assert.cpp (contents, props changed)
Text files modified:
   trunk/boost/xpressive/detail/core/matcher/action_matcher.hpp | 2 +-
   trunk/boost/xpressive/detail/core/matcher/predicate_matcher.hpp | 2 +-
   trunk/boost/xpressive/detail/static/transforms/as_independent.hpp | 4 ++--
   trunk/boost/xpressive/detail/static/transforms/as_set.hpp | 2 +-
   trunk/boost/xpressive/proto/matches.hpp | 7 +++++++
   trunk/boost/xpressive/traits/c_regex_traits.hpp | 6 +++---
   trunk/libs/xpressive/test/Jamfile.v2 | 5 ++++-
   7 files changed, 19 insertions(+), 9 deletions(-)

Modified: trunk/boost/xpressive/detail/core/matcher/action_matcher.hpp
==============================================================================
--- trunk/boost/xpressive/detail/core/matcher/action_matcher.hpp (original)
+++ trunk/boost/xpressive/detail/core/matcher/action_matcher.hpp 2007-10-10 14:13:18 EDT (Wed, 10 Oct 2007)
@@ -238,7 +238,7 @@
 
         template<typename Expr, typename State, typename Visitor>
         static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &state, Visitor &visitor)
+ call(Expr const &, State const &state, Visitor &visitor)
         {
             sub_match<typename State::iterator> const &sub = state.sub_matches_[ visitor ];
             return proto::as_expr(sub);

Modified: trunk/boost/xpressive/detail/core/matcher/predicate_matcher.hpp
==============================================================================
--- trunk/boost/xpressive/detail/core/matcher/predicate_matcher.hpp (original)
+++ trunk/boost/xpressive/detail/core/matcher/predicate_matcher.hpp 2007-10-10 14:13:18 EDT (Wed, 10 Oct 2007)
@@ -54,7 +54,7 @@
         struct eval_terminal<Expr, any_matcher>
         {
             typedef sub_match<BidiIter> const &result_type;
- result_type operator()(Expr &expr, predicate_context const &ctx) const
+ result_type operator()(Expr &, predicate_context const &ctx) const
             {
                 return ctx.sub_matches_[ctx.sub_];
             }

Modified: trunk/boost/xpressive/detail/static/transforms/as_independent.hpp
==============================================================================
--- trunk/boost/xpressive/detail/static/transforms/as_independent.hpp (original)
+++ trunk/boost/xpressive/detail/static/transforms/as_independent.hpp 2007-10-10 14:13:18 EDT (Wed, 10 Oct 2007)
@@ -63,7 +63,7 @@
 
         template<typename Expr, typename State, typename Visitor>
         static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &state, Visitor &visitor)
+ call(Expr const &expr, State const &, Visitor &visitor)
         {
             typename Grammar::template apply<Expr, true_xpression, Visitor>::type const &
                 expr2 = Grammar::call(expr, true_xpression(), visitor);
@@ -88,7 +88,7 @@
 
         template<typename Expr, typename State, typename Visitor>
         static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &state, Visitor &visitor)
+ call(Expr const &expr, State const &, Visitor &visitor)
         {
             return typename apply<Expr, State, Visitor>::type(
                 Grammar::call(expr, true_xpression(), visitor)

Modified: trunk/boost/xpressive/detail/static/transforms/as_set.hpp
==============================================================================
--- trunk/boost/xpressive/detail/static/transforms/as_set.hpp (original)
+++ trunk/boost/xpressive/detail/static/transforms/as_set.hpp 2007-10-10 14:13:18 EDT (Wed, 10 Oct 2007)
@@ -261,7 +261,7 @@
 
         template<typename Expr, typename State, typename Visitor>
         static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &state, Visitor &visitor)
+ call(Expr const &expr, State const &, Visitor &visitor)
         {
             typedef typename apply<Expr, State, Visitor>::type set_type;
             set_type matcher;

Modified: trunk/boost/xpressive/proto/matches.hpp
==============================================================================
--- trunk/boost/xpressive/proto/matches.hpp (original)
+++ trunk/boost/xpressive/proto/matches.hpp 2007-10-10 14:13:18 EDT (Wed, 10 Oct 2007)
@@ -100,6 +100,13 @@
               : lambda_matches<Expr0, Grammar0>
             {};
 
+ #if BOOST_WORKAROUND(__GNUC__, BOOST_TESTED_AT(4))
+ template<template<typename> class T, typename Expr0>
+ struct lambda_matches<T<Expr0>, T<proto::_> BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(1) >
+ : mpl::true_
+ {};
+ #endif
+
             // vararg_matches_impl
             template<typename Args1, typename Back, long From, long To>
             struct vararg_matches_impl;

Modified: trunk/boost/xpressive/traits/c_regex_traits.hpp
==============================================================================
--- trunk/boost/xpressive/traits/c_regex_traits.hpp (original)
+++ trunk/boost/xpressive/traits/c_regex_traits.hpp 2007-10-10 14:13:18 EDT (Wed, 10 Oct 2007)
@@ -135,7 +135,7 @@
     /// Checks two c_regex_traits objects for equality
     ///
     /// \return true.
- bool operator ==(c_regex_traits<char_type> const &that) const
+ bool operator ==(c_regex_traits<char_type> const &) const
     {
         return true;
     }
@@ -143,7 +143,7 @@
     /// Checks two c_regex_traits objects for inequality
     ///
     /// \return false.
- bool operator !=(c_regex_traits<char_type> const &that) const
+ bool operator !=(c_regex_traits<char_type> const &) const
     {
         return false;
     }
@@ -201,7 +201,7 @@
 
     /// Returns a string_type containing all the characters that compare equal
     /// disregrarding case to the one passed in. This function can only be called
- /// if has_fold_case<cc_regex_traits<Char> >::value is true.
+ /// if has_fold_case<c_regex_traits<Char> >::value is true.
     ///
     /// \param ch The source character.
     /// \return string_type containing all chars which are equal to ch when disregarding

Modified: trunk/libs/xpressive/test/Jamfile.v2
==============================================================================
--- trunk/libs/xpressive/test/Jamfile.v2 (original)
+++ trunk/libs/xpressive/test/Jamfile.v2 2007-10-10 14:13:18 EDT (Wed, 10 Oct 2007)
@@ -7,12 +7,14 @@
 
 project
     : requirements
-# <toolset>gcc:<cxxflags>-ftemplate-depth-1024
         <toolset>intel:<debug-symbols>off
         <toolset>msvc-7.1:<debug-symbols>off
         <toolset>msvc-8.0:<define>_SCL_SECURE_NO_DEPRECATE
         <toolset>msvc-8.0:<define>_CRT_SECURE_NO_DEPRECATE
         <toolset>gcc:<cxxflags>-ftemplate-depth-1024
+# <toolset>gcc:<cxxflags>-W
+# <toolset>gcc:<cxxflags>-Wall
+# <toolset>msvc:<cxxflags>-W4
         <toolset>msvc,<stdlib>stlport:<define>_STLP_EXPOSE_GLOBALS_IMPLEMENTATION
         <library>/boost/test//boost_unit_test_framework
         <link>static
@@ -49,6 +51,7 @@
          [ run test_non_char.cpp ]
          [ run test_static.cpp ]
          [ run test_actions.cpp ]
+ [ run test_assert.cpp ]
          [ run test_symbols.cpp ]
          [ run test_dynamic.cpp ]
          [ run test_dynamic_grammar.cpp ]

Added: trunk/libs/xpressive/test/test_assert.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/xpressive/test/test_assert.cpp 2007-10-10 14:13:18 EDT (Wed, 10 Oct 2007)
@@ -0,0 +1,65 @@
+///////////////////////////////////////////////////////////////////////////////
+// test_assert.cpp
+//
+// Copyright 2004 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)
+
+#include <map>
+#include <list>
+#include <stack>
+#include <numeric>
+#include <boost/version.hpp>
+#include <boost/xpressive/xpressive_static.hpp>
+#include <boost/xpressive/regex_actions.hpp>
+#include <boost/test/unit_test.hpp>
+
+using namespace boost::xpressive;
+
+struct three_or_six
+{
+ bool operator()(ssub_match const &sub) const
+ {
+ return sub.length() == 3 || sub.length() == 6;
+ }
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// test1
+// simple custom assert that checks the length of a matched sub-expression
+void test1()
+{
+ std::string str("foo barbaz fink");
+ // match words of 3 characters or 6 characters.
+ sregex rx = (bow >> +_w >> eow)[ check(three_or_six()) ] ;
+
+ sregex_iterator first(str.begin(), str.end(), rx), last;
+ BOOST_CHECK_EQUAL(std::distance(first, last), 2);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// test2
+// same as above, but using a lambda
+void test2()
+{
+ std::string str("foo barbaz fink");
+ // match words of 3 characters or 6 characters.
+ sregex rx = (bow >> +_w >> eow)[ check(length(_)==3 || length(_)==6) ] ;
+
+ sregex_iterator first(str.begin(), str.end(), rx), last;
+ BOOST_CHECK_EQUAL(std::distance(first, last), 2);
+}
+
+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_assert");
+ test->add(BOOST_TEST_CASE(&test1));
+ test->add(BOOST_TEST_CASE(&test2));
+ 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