Skip to content

Commit

Permalink
V2.Tests: Revise poorly named tests
Browse files Browse the repository at this point in the history
Looking by the commit history they should not have been using classic iterators
  • Loading branch information
Kojoley committed Apr 2, 2023
1 parent 94f4704 commit 32fb6f6
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 167 deletions.
8 changes: 4 additions & 4 deletions test/lex/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ run regression_matlib_switch.cpp : : : <dependency>lex_regression_matl
run regression_word_count.cpp ;
run regression_syntax_error.cpp ;
run regression_wide.cpp ;
run regression_file_iterator1.cpp ;
run regression_file_iterator2.cpp ;
run regression_file_iterator3.cpp : : : <pch>off ;
run regression_file_iterator4.cpp ;
run state_any_token_semact.cpp ;
run multi_pass.cpp ;
run lookahead.cpp : : : <pch>off ;
run bol_reset.cpp ;
run regression_static_wide_6253.cpp ;
run regression_less_8563.cpp ;
27 changes: 5 additions & 22 deletions test/lex/auto_switch_lexerstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@

#include <boost/spirit/include/lex_lexertl.hpp>

#include <boost/spirit/include/support_multi_pass.hpp>
#include <boost/spirit/include/classic_position_iterator.hpp>

#include <boost/core/lightweight_test.hpp>
#include <boost/phoenix/operator/self.hpp>

Expand All @@ -23,21 +20,8 @@
namespace spirit = boost::spirit;
namespace lex = spirit::lex;

typedef spirit::classic::position_iterator2<
spirit::multi_pass<std::istreambuf_iterator<char> >
> file_iterator;

inline file_iterator
make_file_iterator(std::istream& input, const std::string& filename)
{
return file_iterator(
spirit::make_default_multi_pass(
std::istreambuf_iterator<char>(input)),
spirit::multi_pass<std::istreambuf_iterator<char> >(),
filename);
}

typedef lex::lexertl::token<file_iterator> token_type;
typedef char const* content_iterator;
typedef lex::lexertl::token<content_iterator> token_type;

struct lexer
: lex::lexer<lex::lexertl::actor_lexer<token_type> >
Expand Down Expand Up @@ -66,11 +50,10 @@ typedef lexer::iterator_type token_iterator;

int main()
{
std::stringstream ss;
ss << "!foo\nbar\n!baz";
std::string const s = "!foo\nbar\n!baz";

file_iterator begin = make_file_iterator(ss, "SS");
file_iterator end;
content_iterator begin = s.data();
content_iterator end = s.data() + s.size();

lexer l;
token_iterator begin2 = l.begin(begin, end);
Expand Down
26 changes: 5 additions & 21 deletions test/lex/regression_file_iterator4.cpp → test/lex/bol_reset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
// if a token matched at the beginning of a line is discarded using
// lex::pass_fail.

#include <boost/spirit/include/support_multi_pass.hpp>
#include <boost/spirit/include/classic_position_iterator.hpp>
#include <boost/spirit/include/lex_lexertl.hpp>

#include <boost/core/lightweight_test.hpp>
Expand All @@ -21,21 +19,8 @@
namespace spirit = boost::spirit;
namespace lex = spirit::lex;

typedef spirit::classic::position_iterator2<
spirit::multi_pass<std::istreambuf_iterator<char> >
> file_iterator;

inline file_iterator
make_file_iterator(std::istream& input, const std::string& filename)
{
return file_iterator(
spirit::make_default_multi_pass(
std::istreambuf_iterator<char>(input)),
spirit::multi_pass<std::istreambuf_iterator<char> >(),
filename);
}

typedef lex::lexertl::token<file_iterator> token_type;
typedef char const* content_iterator;
typedef lex::lexertl::token<content_iterator> token_type;

struct lexer
: lex::lexer<lex::lexertl::actor_lexer<token_type> >
Expand Down Expand Up @@ -69,11 +54,10 @@ typedef lexer::iterator_type token_iterator;

int main()
{
std::stringstream ss;
ss << "!foo\nbar\n!baz";
std::string const s = "!foo\nbar\n!baz";

file_iterator begin = make_file_iterator(ss, "SS");
file_iterator end;
content_iterator begin = s.data();
content_iterator end = s.data() + s.size();

lexer l;
token_iterator begin2 = l.begin(begin, end);
Expand Down
25 changes: 5 additions & 20 deletions test/lex/id_type_enum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#include <boost/spirit/include/lex_lexertl.hpp>
#include <boost/spirit/include/support_multi_pass.hpp>
#include <boost/spirit/include/classic_position_iterator.hpp>

#include <boost/core/lightweight_test.hpp>
#include <boost/phoenix/operator/self.hpp>
Expand All @@ -16,19 +14,7 @@
namespace spirit = boost::spirit;
namespace lex = spirit::lex;

typedef spirit::classic::position_iterator2<
spirit::multi_pass<std::istreambuf_iterator<char> >
> file_iterator;

inline file_iterator
make_file_iterator(std::istream& input, const std::string& filename)
{
return file_iterator(
spirit::make_default_multi_pass(
std::istreambuf_iterator<char>(input)),
spirit::multi_pass<std::istreambuf_iterator<char> >(),
filename);
}
typedef char const* content_iterator;

enum token_id
{
Expand All @@ -37,7 +23,7 @@ enum token_id
};

typedef lex::lexertl::token<
file_iterator, boost::mpl::vector<>, boost::mpl::true_, token_id
content_iterator, boost::mpl::vector<>, boost::mpl::true_, token_id
> token_type;

struct lexer
Expand Down Expand Up @@ -69,11 +55,10 @@ typedef lexer::iterator_type token_iterator;

int main()
{
std::stringstream ss;
ss << "!foo\nbar\n!baz";
std::string const s = "!foo\nbar\n!baz";

file_iterator begin = make_file_iterator(ss, "SS");
file_iterator end;
content_iterator begin = s.data();
content_iterator end = s.data() + s.size();

lexer l;
token_iterator begin2 = l.begin(begin, end);
Expand Down
29 changes: 6 additions & 23 deletions test/lex/regression_file_iterator3.cpp → test/lex/lookahead.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
#define BOOST_SPIRIT_DEBUG 1 // required for token streaming
// #define BOOST_SPIRIT_LEXERTL_DEBUG 1

#include <boost/spirit/include/support_multi_pass.hpp>
#include <boost/spirit/include/classic_position_iterator.hpp>
#include <boost/spirit/include/lex_lexertl.hpp>

#include <boost/core/lightweight_test.hpp>
Expand All @@ -22,31 +20,17 @@ namespace spirit = boost::spirit;
namespace lex = spirit::lex;
namespace phoenix = boost::phoenix;

typedef spirit::classic::position_iterator2<
spirit::multi_pass<std::istreambuf_iterator<char> >
> file_iterator;

typedef boost::iterator_range<file_iterator> file_range;

inline file_iterator
make_file_iterator(std::istream& input, const std::string& filename)
{
return file_iterator(
spirit::make_default_multi_pass(
std::istreambuf_iterator<char>(input)),
spirit::multi_pass<std::istreambuf_iterator<char> >(),
filename);
}
typedef char const* content_iterator;

struct string_literal
{
string_literal(file_iterator, file_iterator)
string_literal(content_iterator, content_iterator)
{
}
};

typedef lex::lexertl::token<
file_iterator, boost::mpl::vector<string_literal>
content_iterator, boost::mpl::vector<string_literal>
> token_type;

struct lexer
Expand All @@ -72,11 +56,10 @@ typedef lexer::iterator_type token_iterator;

int main()
{
std::stringstream ss;
ss << "'foo''bar'";
std::string const s = "'foo''bar'";

file_iterator begin = make_file_iterator(ss, "SS");
file_iterator end;
content_iterator begin = s.data();
content_iterator end = s.data() + s.size();

lexer l;
token_iterator begin2 = l.begin(begin, end);
Expand Down
30 changes: 9 additions & 21 deletions test/lex/regression_file_iterator2.cpp → test/lex/multi_pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
// 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)

// problem in multi_pass showing up in conjunction with certain lexer usage patterns

#include <boost/spirit/include/support_multi_pass.hpp>
#include <boost/spirit/include/classic_position_iterator.hpp>
#include <boost/spirit/include/lex_lexertl.hpp>

#include <boost/core/lightweight_test.hpp>
Expand All @@ -17,36 +18,24 @@
namespace spirit = boost::spirit;
namespace lex = spirit::lex;

typedef spirit::classic::position_iterator2<
spirit::multi_pass<std::istreambuf_iterator<char> >
> file_iterator;

inline file_iterator
make_file_iterator(std::istream& input, const std::string& filename)
{
return file_iterator(
spirit::make_default_multi_pass(
std::istreambuf_iterator<char>(input)),
spirit::multi_pass<std::istreambuf_iterator<char> >(),
filename);
}
typedef char const* content_iterator;

struct identifier
{
identifier(file_iterator, file_iterator)
identifier(content_iterator, content_iterator)
{
}
};

struct string_literal
{
string_literal(file_iterator, file_iterator)
string_literal(content_iterator, content_iterator)
{
}
};

typedef lex::lexertl::token<
file_iterator, boost::mpl::vector<identifier, string_literal>
content_iterator, boost::mpl::vector<identifier, string_literal>
> token_type;

struct lexer
Expand Down Expand Up @@ -83,11 +72,10 @@ typedef lexer::iterator_type token_iterator;

int main()
{
std::stringstream ss;
ss << "foo 'bar'";
std::string const s = "foo 'bar'";

file_iterator begin = make_file_iterator(ss, "SS");
file_iterator end;
content_iterator begin = s.data();
content_iterator end = s.data() + s.size();

lexer l;
token_iterator begin2 = l.begin(begin, end, "ST");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// 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 <boost/spirit/include/support_multi_pass.hpp>
#include <boost/spirit/include/classic_position_iterator.hpp>
// lexers with semantic actions attached to state '*' tokens

#include <boost/spirit/include/lex_lexertl.hpp>

#include <boost/core/lightweight_test.hpp>
Expand All @@ -16,38 +16,24 @@
namespace spirit = boost::spirit;
namespace lex = spirit::lex;

typedef spirit::classic::position_iterator2<
spirit::multi_pass<std::istreambuf_iterator<char> >
> file_iterator;

typedef boost::iterator_range<file_iterator> file_range;

inline file_iterator
make_file_iterator(std::istream& input, const std::string& filename)
{
return file_iterator(
spirit::make_default_multi_pass(
std::istreambuf_iterator<char>(input)),
spirit::multi_pass<std::istreambuf_iterator<char> >(),
filename);
}
typedef char const* content_iterator;

struct identifier
{
identifier(file_iterator, file_iterator)
identifier(content_iterator, content_iterator)
{
}
};

struct string_literal
{
string_literal(file_iterator, file_iterator)
string_literal(content_iterator, content_iterator)
{
}
};

typedef lex::lexertl::token<
file_iterator, boost::mpl::vector<identifier, string_literal>
content_iterator, boost::mpl::vector<identifier, string_literal>
> token_type;

struct lexer
Expand Down Expand Up @@ -75,11 +61,10 @@ typedef lexer::iterator_type token_iterator;

int main()
{
std::stringstream ss;
ss << "foo 'bar'";
std::string const s = "foo 'bar'";

file_iterator begin = make_file_iterator(ss, "SS");
file_iterator end;
content_iterator begin = s.data();
content_iterator end = s.data() + s.size();

lexer l;
token_iterator begin2 = l.begin(begin, end, "ST");
Expand Down
1 change: 0 additions & 1 deletion test/support/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,3 @@ run utree.cpp ;
run utree_debug.cpp ;

compile multi_pass_functor.cpp ;
compile multi_pass_position_iterator.cpp ;
31 changes: 0 additions & 31 deletions test/support/multi_pass_position_iterator.cpp

This file was deleted.

0 comments on commit 32fb6f6

Please sign in to comment.