Update of /cvsroot/boost/boost/libs/spirit/test
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv25300
Modified Files:
Jamfile.v2 Jamfile
Added Files:
post_skips.cpp
Log Message:
Added a simple test for detecting post-skips.
--- NEW FILE: post_skips.cpp ---
/*=============================================================================
Copyright (c) 2004 Joao Abecasis
http://spirit.sourceforge.net/
Use, modification and distribution is subject to 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 <boost/spirit/core/parser.hpp>
#include <boost/spirit/core/scanner/skipper.hpp>
#include <boost/spirit/core/primitives/primitives.hpp>
#include <boost/spirit/core/composite/optional.hpp>
#include <boost/spirit/core/composite/sequence.hpp>
#include <boost/spirit/tree/ast.hpp>
#include <boost/spirit/tree/parse_tree.hpp>
#include <boost/detail/lightweight_test.hpp>
using namespace boost::spirit;
char const * test1 = " 12345 ";
char const * test2 = " 12345 x";
void parse_tests()
{
parse_info<> info;
// Warming up...
info = parse(test1, str_p("12345"));
BOOST_TEST(!info.hit);
// No post-skips!
info = parse(test1, str_p("12345"), blank_p);
BOOST_TEST(info.hit);
BOOST_TEST(!info.full);
// Require a full match
info = parse(test1, str_p("12345") >> end_p, blank_p);
BOOST_TEST(info.full);
info = parse(test2, str_p("12345") >> end_p, blank_p);
BOOST_TEST(!info.hit);
// Check for a full match but don't make it a requirement
info = parse(test1, str_p("12345") >> !end_p, blank_p);
BOOST_TEST(info.full);
info = parse(test2, str_p("12345") >> !end_p, blank_p);
BOOST_TEST(info.hit);
BOOST_TEST(!info.full);
}
void ast_parse_tests()
{
tree_parse_info<> info;
// Warming up...
info = ast_parse(test1, str_p("12345"));
BOOST_TEST(!info.match);
// No post-skips!
info = ast_parse(test1, str_p("12345"), blank_p);
BOOST_TEST(info.match);
BOOST_TEST(!info.full);
// Require a full match
info = ast_parse(test1, str_p("12345") >> end_p, blank_p);
BOOST_TEST(info.full);
info = ast_parse(test2, str_p("12345") >> end_p, blank_p);
BOOST_TEST(!info.match);
// Check for a full match but don't make it a requirement
info = ast_parse(test1, str_p("12345") >> !end_p, blank_p);
BOOST_TEST(info.full);
info = ast_parse(test2, str_p("12345") >> !end_p, blank_p);
BOOST_TEST(info.match);
BOOST_TEST(!info.full);
}
void pt_parse_tests()
{
tree_parse_info<> info;
// Warming up...
info = pt_parse(test1, str_p("12345"));
BOOST_TEST(!info.match);
// No post-skips!
info = pt_parse(test1, str_p("12345"), blank_p);
BOOST_TEST(info.match);
BOOST_TEST(!info.full);
// Require a full match
info = pt_parse(test1, str_p("12345") >> end_p, blank_p);
BOOST_TEST(info.full);
info = pt_parse(test2, str_p("12345") >> end_p, blank_p);
BOOST_TEST(!info.match);
// Check for a full match but don't make it a requirement
info = pt_parse(test1, str_p("12345") >> !end_p, blank_p);
BOOST_TEST(info.full);
info = pt_parse(test2, str_p("12345") >> !end_p, blank_p);
BOOST_TEST(info.match);
BOOST_TEST(!info.full);
}
int main()
{
parse_tests();
ast_parse_tests();
pt_parse_tests();
return boost::report_errors();
}
Index: Jamfile.v2
===================================================================
RCS file: /cvsroot/boost/boost/libs/spirit/test/Jamfile.v2,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- Jamfile.v2 7 Apr 2006 13:44:32 -0000 1.6
+++ Jamfile.v2 27 Jun 2007 00:53:57 -0000 1.7
@@ -48,6 +48,7 @@
test-suite "spirit.core.kernel"
: [ spirit-run match_tests.cpp ]
+ [ spirit-run post_skips.cpp ]
;
test-suite "spirit.core.scanner"
Index: Jamfile
===================================================================
RCS file: /cvsroot/boost/boost/libs/spirit/test/Jamfile,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- Jamfile 20 Mar 2006 23:27:20 -0000 1.42
+++ Jamfile 27 Jun 2007 00:53:57 -0000 1.43
@@ -95,6 +95,7 @@
test-suite "spirit.core.kernel"
: [ spirit-run $(spirit-src)match_tests.cpp <template>normal ]
+ [ spirit-run $(spirit-src)post_skips.cpp <template>normal ]
;
test-suite "spirit.core.scanner"
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs