Skip to content

Commit 0a09ee1

Browse files
authored
Merge pull request #489 from aycabta/fix-not-equal-handling
Separate "foo!=bar" to "foo", "!=" and "bar"
2 parents 8fc1624 + c1c16de commit 0a09ee1

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lib/rdoc/ruby_lex.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,7 @@ def identify_identifier
985985

986986
ungetc
987987

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

test/test_rdoc_ruby_lex.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,5 +773,22 @@ def test_class_tokenize_constant_with_exclamation
773773
assert_equal expected, tokens
774774
end
775775

776+
def test_class_tokenize_identifer_not_equal
777+
tokens = RDoc::RubyLex.tokenize "foo!=bar\nfoo?=bar", nil
778+
779+
expected = [
780+
@TK::TkIDENTIFIER.new( 0, 1, 0, "foo"),
781+
@TK::TkNEQ .new( 3, 1, 3, "!="),
782+
@TK::TkIDENTIFIER.new( 5, 1, 5, "bar"),
783+
@TK::TkNL .new( 8, 1, 8, "\n"),
784+
@TK::TkFID .new( 9, 2, 0, "foo?"),
785+
@TK::TkASSIGN .new(13, 2, 4, "="),
786+
@TK::TkIDENTIFIER.new(14, 2, 5, "bar"),
787+
@TK::TkNL .new(17, 2, 9, "\n"),
788+
]
789+
790+
assert_equal expected, tokens
791+
end
792+
776793
end
777794

0 commit comments

Comments
 (0)