Commit a435de0e authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner

[2427] Find INITIAL_WS even at the beginning of file

parent f74f25e7
......@@ -37,7 +37,7 @@ using namespace master_lexer_internal;
struct MasterLexer::MasterLexerImpl {
MasterLexerImpl() : source_(NULL), token_(MasterToken::NOT_STARTED),
paren_count_(0), last_was_eol_(false),
paren_count_(0), last_was_eol_(true),
has_previous_(false),
previous_paren_count_(0),
previous_was_eol_(false)
......
......@@ -54,7 +54,8 @@ public:
END_OF_LINE, ///< End of line detected
END_OF_FILE, ///< End of file detected
INITIAL_WS, ///< White spaces at the beginning of a line after an
///< end of line (if asked for detecting it)
///< end of line or at the beginning of file (if asked
// for detecting it)
NOVALUE_TYPE_MAX = INITIAL_WS, ///< Max integer corresponding to
/// no-value (type only) types.
/// Mainly for internal use.
......
......@@ -190,13 +190,16 @@ TEST_F(MasterLexerStateTest, unbalancedParentheses) {
}
TEST_F(MasterLexerStateTest, startToComment) {
// Begin with 'start', skip space, then encounter a comment. Skip
// Begin with 'start', detect space, then encounter a comment. Skip
// the rest of the line, and recognize the new line. Note that the
// second ';' is simply ignored.
ss << " ;a;\n";
ss << ";a;"; // Likewise, but the comment ends with EOF.
lexer.pushSource(ss);
// Initial whitespace (asked for in common_options)
EXPECT_EQ(s_null, State::start(lexer, common_options));
EXPECT_EQ(Token::INITIAL_WS, s_crlf.getToken(lexer).getType());
// Comment ending with EOL
EXPECT_EQ(s_null, State::start(lexer, common_options));
EXPECT_EQ(Token::END_OF_LINE, s_crlf.getToken(lexer).getType());
......
......@@ -238,10 +238,8 @@ TEST_F(MasterLexerTest, ungetToken) {
// Check ungetting token without overriding the start method. We also
// check it works well with changing options between the calls.
TEST_F(MasterLexerTest, ungetRealOptions) {
ss << "\n \n";
ss << " \n";
lexer.pushSource(ss);
// Skip the first newline
EXPECT_EQ(MasterToken::END_OF_LINE, lexer.getNextToken().getType());
// If we call it the usual way, it skips up to the newline and returns
// it
......
......@@ -789,9 +789,8 @@ TEST_F(MasterLoaderTest, noPreviousName) {
loader_->load();
EXPECT_FALSE(loader_->loadedSucessfully());
EXPECT_EQ(1, errors_.size());
checkCallbackMessage(errors_.at(0),
"x",
1);
checkCallbackMessage(errors_.at(0), "No previous name to use in place of "
"initial whitespace", 1);
EXPECT_TRUE(warnings_.empty());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment