|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r68487 - in trunk: boost/spirit/home/qi/numeric libs/spirit/test libs/spirit/test/qi
From: admin_at_[hidden]
Date: 2011-01-27 15:30:14
Author: wash
Date: 2011-01-27 15:30:12 EST (Thu, 27 Jan 2011)
New Revision: 68487
URL: http://svn.boost.org/trac/boost/changeset/68487
Log:
Added regression tests and fixes for Spirit.Qi numeric literal alternatives issue.
Added:
trunk/libs/spirit/test/qi/regression_numeric_alternatives.cpp (contents, props changed)
Text files modified:
trunk/boost/spirit/home/qi/numeric/int.hpp | 4 +++-
trunk/boost/spirit/home/qi/numeric/real.hpp | 4 +++-
trunk/boost/spirit/home/qi/numeric/uint.hpp | 4 +++-
trunk/libs/spirit/test/Jamfile | 1 +
4 files changed, 10 insertions(+), 3 deletions(-)
Modified: trunk/boost/spirit/home/qi/numeric/int.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/numeric/int.hpp (original)
+++ trunk/boost/spirit/home/qi/numeric/int.hpp 2011-01-27 15:30:12 EST (Thu, 27 Jan 2011)
@@ -236,7 +236,8 @@
{
typedef extract_int<T, Radix, MinDigits, MaxDigits> extract;
qi::skip_over(first, last, skipper);
-
+
+ Iterator save = first;
T attr_;
if (extract::call(first, last, attr_) && (attr_ == n_))
@@ -245,6 +246,7 @@
return true;
}
+ first = save;
return false;
}
Modified: trunk/boost/spirit/home/qi/numeric/real.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/numeric/real.hpp (original)
+++ trunk/boost/spirit/home/qi/numeric/real.hpp 2011-01-27 15:30:12 EST (Thu, 27 Jan 2011)
@@ -104,7 +104,7 @@
struct use_lazy_terminal<qi::domain, tag::double_, 1>
: mpl::true_ {};
- template <> // enables *lazy* double_(...)
+ template <> // enables *lazy* long_double_(...)
struct use_lazy_terminal<qi::domain, tag::long_double, 1>
: mpl::true_ {};
@@ -210,6 +210,7 @@
typedef detail::real_impl<T, RealPolicies> extract;
qi::skip_over(first, last, skipper);
+ Iterator save = first;
T attr_;
if (extract::parse(first, last, attr_, RealPolicies()) &&
@@ -219,6 +220,7 @@
return true;
}
+ first = save;
return false;
}
Modified: trunk/boost/spirit/home/qi/numeric/uint.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/numeric/uint.hpp (original)
+++ trunk/boost/spirit/home/qi/numeric/uint.hpp 2011-01-27 15:30:12 EST (Thu, 27 Jan 2011)
@@ -263,7 +263,8 @@
{
typedef extract_uint<T, Radix, MinDigits, MaxDigits> extract;
qi::skip_over(first, last, skipper);
-
+
+ Iterator save = first;
T attr_;
if (extract::call(first, last, attr_) && (attr_ == n_))
@@ -272,6 +273,7 @@
return true;
}
+ first = save;
return false;
}
Modified: trunk/libs/spirit/test/Jamfile
==============================================================================
--- trunk/libs/spirit/test/Jamfile (original)
+++ trunk/libs/spirit/test/Jamfile 2011-01-27 15:30:12 EST (Thu, 27 Jan 2011)
@@ -106,6 +106,7 @@
[ run qi/regression_clear.cpp : : : : qi_regression_clear ]
#[ run qi/regression_float_fraction.cpp : : : : qi_regression_float_fraction ]
[ run qi/regression_lazy_repeat.cpp : : : : qi_regression_lazy_repeat ]
+ [ run qi/regression_numeric_alternatives.cpp : : : : qi_regression_numeric_alternatives ]
[ run qi/regression_reorder.cpp : : : : qi_regression_reorder ]
[ run qi/regression_repeat.cpp : : : : qi_regression_repeat ]
[ run qi/regression_transform_assignment.cpp : : : : qi_regression_transform_assignment ]
Added: trunk/libs/spirit/test/qi/regression_numeric_alternatives.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/qi/regression_numeric_alternatives.cpp 2011-01-27 15:30:12 EST (Thu, 27 Jan 2011)
@@ -0,0 +1,74 @@
+// Copyright (c) 2011 Bryce Lelbach
+//
+// 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 "test.hpp"
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/spirit/include/qi.hpp>
+
+int main() {
+ using spirit_test::test;
+ using boost::spirit::qi::rule;
+ using boost::spirit::qi::parse;
+ using boost::spirit::qi::int_;
+ using boost::spirit::qi::uint_;
+ using boost::spirit::qi::short_;
+ using boost::spirit::qi::ushort_;
+ using boost::spirit::qi::long_;
+ using boost::spirit::qi::ulong_;
+ using boost::spirit::qi::float_;
+ using boost::spirit::qi::double_;
+ using boost::spirit::qi::long_double;
+ using boost::spirit::qi::bool_;
+
+#ifdef BOOST_HAS_LONG_LONG
+ using boost::spirit::qi::long_long;
+ using boost::spirit::qi::ulong_long;
+#endif
+
+ BOOST_TEST(test("-123", short_(0) | short_(-123)));
+ BOOST_TEST(test("-123", short_(-123) | short_(0)));
+
+ BOOST_TEST(test("123", ushort_(0) | ushort_(123)));
+ BOOST_TEST(test("123", ushort_(123) | ushort_(0)));
+
+ BOOST_TEST(test("-123456", int_(0) | int_(-123456)));
+ BOOST_TEST(test("-123456", int_(-123456) | int_(0)));
+
+ BOOST_TEST(test("123456", uint_(0) | uint_(123456)));
+ BOOST_TEST(test("123456", uint_(123456) | uint_(0)));
+
+ BOOST_TEST(test("-123456789", long_(0) | long_(-123456789L)));
+ BOOST_TEST(test("-123456789", long_(-123456789L) | long_(0)));
+
+ BOOST_TEST(test("123456789", ulong_(0) | ulong_(123456789UL)));
+ BOOST_TEST(test("123456789", ulong_(123456789UL) | ulong_(0)));
+
+#ifdef BOOST_HAS_LONG_LONG
+ BOOST_TEST(test("-1234567890123456789",
+ long_long(0) | long_long(-1234567890123456789LL)));
+ BOOST_TEST(test("-1234567890123456789",
+ long_long(-1234567890123456789LL) | long_long(0)));
+
+ BOOST_TEST(test("1234567890123456789",
+ ulong_long(0) | ulong_long(1234567890123456789ULL)));
+ BOOST_TEST(test("1234567890123456789",
+ ulong_long(1234567890123456789ULL) | ulong_long(0)));
+#endif
+
+ BOOST_TEST(test("1.23", float_(0) | float_(1.23f)));
+ BOOST_TEST(test("1.23", float_(1.23f) | float_(0)));
+
+ BOOST_TEST(test("123.456", double_(0) | double_(123.456)));
+ BOOST_TEST(test("123.456", double_(123.456) | double_(0)));
+
+ BOOST_TEST(test("123456.789", long_double(0) | long_double(123456.789l)));
+ BOOST_TEST(test("123456.789", long_double(123456.789l) | long_double(0)));
+
+ BOOST_TEST(test("true", bool_(false) | bool_(true)));
+ BOOST_TEST(test("true", bool_(true) | bool_(false)));
+
+ 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