Skip to content

Commit a4baf6a

Browse files
authored
Merge pull request #481 from aycabta/fix-n-ary-detecting
Fix n-ary detecting condition for rational and imaginary
2 parents d3f8522 + a353417 commit a4baf6a

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lib/rdoc/ruby_lex.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1170,7 +1170,7 @@ def identify_number(op = "")
11701170

11711171
num = op
11721172

1173-
if peek(0) == "0" && peek(1) !~ /[.eE]/
1173+
if peek(0) == "0" && peek(1) !~ /[.eEri]/
11741174
num << getc
11751175

11761176
case peek(0)

test/test_rdoc_ruby_lex.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ def test_unary_minus
527527
end
528528

529529
def test_rational_imaginary_tokenize
530-
tokens = RDoc::RubyLex.tokenize '1.11r + 2.34i + 5.55ri', nil
530+
tokens = RDoc::RubyLex.tokenize '1.11r + 2.34i + 5.55ri + 0i', nil
531531

532532
expected = [
533533
@TK::TkRATIONAL .new( 0, 1, 0, '1.11r'),
@@ -539,7 +539,11 @@ def test_rational_imaginary_tokenize
539539
@TK::TkPLUS .new(14, 1, 14, '+'),
540540
@TK::TkSPACE .new(15, 1, 15, ' '),
541541
@TK::TkIMAGINARY.new(16, 1, 16, '5.55ri'),
542-
@TK::TkNL .new(22, 1, 22, "\n"),
542+
@TK::TkSPACE .new(22, 1, 22, ' '),
543+
@TK::TkPLUS .new(23, 1, 23, '+'),
544+
@TK::TkSPACE .new(24, 1, 24, ' '),
545+
@TK::TkIMAGINARY.new(25, 1, 25, '0i'),
546+
@TK::TkNL .new(27, 1, 27, "\n"),
543547
]
544548

545549
assert_equal expected, tokens

0 commit comments

Comments
 (0)