Skip to content

Separate "foo!=bar" to "foo", "!=" and "bar" #489

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rdoc/ruby_lex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ def identify_identifier

ungetc

if (ch == "!" || ch == "?") && token[0,1] =~ /\w/ && peek(0) != "="
if ((ch == "!" && peek(1) != "=") || ch == "?") && token[0,1] =~ /\w/
token.concat getc
end

Expand Down
17 changes: 17 additions & 0 deletions test/test_rdoc_ruby_lex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -595,5 +595,22 @@ def test_class_tokenize_constant_with_exclamation
assert_equal expected, tokens
end

def test_class_tokenize_identifer_not_equal
tokens = RDoc::RubyLex.tokenize "foo!=bar\nfoo?=bar", nil

expected = [
@TK::TkIDENTIFIER.new( 0, 1, 0, "foo"),
@TK::TkNEQ .new( 3, 1, 3, "!="),
@TK::TkIDENTIFIER.new( 5, 1, 5, "bar"),
@TK::TkNL .new( 8, 1, 8, "\n"),
@TK::TkFID .new( 9, 2, 0, "foo?"),
@TK::TkASSIGN .new(13, 2, 4, "="),
@TK::TkIDENTIFIER.new(14, 2, 5, "bar"),
@TK::TkNL .new(17, 2, 9, "\n"),
]

assert_equal expected, tokens
end

end