Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r56789 - in trunk/libs/spirit: example/karma test/karma
From: hartmut.kaiser_at_[hidden]
Date: 2009-10-13 12:20:38


Author: hkaiser
Date: 2009-10-13 12:20:36 EDT (Tue, 13 Oct 2009)
New Revision: 56789
URL: http://svn.boost.org/trac/boost/changeset/56789

Log:
Spirit: updating examples and tests
Text files modified:
   trunk/libs/spirit/example/karma/generate_code.cpp | 5 +++--
   trunk/libs/spirit/example/karma/reference.cpp | 4 ++--
   trunk/libs/spirit/test/karma/alternative.cpp | 16 ++++++++++++++++
   3 files changed, 21 insertions(+), 4 deletions(-)

Modified: trunk/libs/spirit/example/karma/generate_code.cpp
==============================================================================
--- trunk/libs/spirit/example/karma/generate_code.cpp (original)
+++ trunk/libs/spirit/example/karma/generate_code.cpp 2009-10-13 12:20:36 EDT (Tue, 13 Oct 2009)
@@ -37,9 +37,10 @@
             using karma::_val;
             using karma::_r1;
 
- start = array_def(phoenix::size(_val)) << " = " << initializer << eol;
+ start = array_def(phoenix::size(_val)) << " = " << initializer
+ << ';' << eol;
             array_def = "int " << lit(name) << "[" << uint_(_r1) << "]";
- initializer = "{ " << -(int_ % ", ") << " };";
+ initializer = "{ " << -(int_ % ", ") << " }";
         }
 
         karma::rule<Iterator, void(unsigned)> array_def;

Modified: trunk/libs/spirit/example/karma/reference.cpp
==============================================================================
--- trunk/libs/spirit/example/karma/reference.cpp (original)
+++ trunk/libs/spirit/example/karma/reference.cpp 2009-10-13 12:20:36 EDT (Tue, 13 Oct 2009)
@@ -133,7 +133,7 @@
 namespace boost { namespace spirit { namespace traits
 {
     template <>
- struct transform_attribute<int, int_data const>
+ struct transform_attribute<int_data const, int>
     {
         static int pre(int_data const& d) { return d.i; }
     };
@@ -533,7 +533,7 @@
 
         //[reference_karma_attr_cast1
         int_data d = { 1 };
- test_generator("1", karma::attr_cast<int>(karma::int_), d);
+ test_generator("1", karma::attr_cast(karma::int_), d);
         //]
     }
 

Modified: trunk/libs/spirit/test/karma/alternative.cpp
==============================================================================
--- trunk/libs/spirit/test/karma/alternative.cpp (original)
+++ trunk/libs/spirit/test/karma/alternative.cpp 2009-10-13 12:20:36 EDT (Tue, 13 Oct 2009)
@@ -15,6 +15,7 @@
 #include <boost/spirit/include/karma_generate.hpp>
 #include <boost/spirit/include/karma_operator.hpp>
 #include <boost/spirit/include/karma_directive.hpp>
+#include <boost/spirit/include/karma_nonterminal.hpp>
 
 #include "test.hpp"
 
@@ -138,6 +139,21 @@
         BOOST_TEST(test("1", int_ | "error" << omit[int_], v));
     }
 
+ {
+ typedef spirit_test::output_iterator<char>::type outiter_type;
+ namespace karma = boost::spirit::karma;
+
+ karma::rule<outiter_type, int()> r = int_;
+ std::vector<int> v;
+ BOOST_TEST(test("", '>' << r % ',' | karma::eps, v));
+
+ v.push_back(1);
+ v.push_back(2);
+ v.push_back(3);
+ v.push_back(4);
+ BOOST_TEST(test(">1,2,3,4", '>' << r % ',' | karma::eps, v));
+ }
+
     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