Skip to content
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
8 changes: 6 additions & 2 deletions lib/rdoc/parser/ruby_colorizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@ module RDoc::Parser::RubyColorizer
CONSTANT: :constant,
LABEL: :value,
INTEGER: :value,
INTEGER_IMAGINARY: :value,
INTEGER_RATIONAL: :value,
INTEGER_RATIONAL_IMAGINARY: :value,
FLOAT: :value,
RATIONAL: :value,
IMAGINARY: :value,
FLOAT_IMAGINARY: :value,
FLOAT_RATIONAL: :value,
FLOAT_RATIONAL_IMAGINARY: :value,
Comment on lines 34 to +43
Comment on lines 36 to +43
COMMENT: :comment,
EMBDOC_BEGIN: :comment,
EMBDOC_LINE: :comment,
Expand Down
21 changes: 21 additions & 0 deletions test/rdoc/parser/ruby_colorizer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,25 @@ def f
assert_include(tokens, token(:string, '}'))
assert_include(tokens, token(:string, " heredoc\n"))
end

def test_rational_imaginary
code = <<~RUBY
2i
2r
2ri

2.0i
2.0r
2.0ri
RUBY
tokens = RDoc::Parser::RubyColorizer.colorize(code)
assert_equal(code, tokens.map(&:text).join)

assert_include(tokens, token(:value, "2i"))
assert_include(tokens, token(:value, "2r"))
assert_include(tokens, token(:value, "2ri"))
assert_include(tokens, token(:value, "2.0i"))
assert_include(tokens, token(:value, "2.0r"))
assert_include(tokens, token(:value, "2.0ri"))
end
end