Skip to content

Commit fff6970

Browse files
authored
Merge pull request #553 from aycabta/remove-unnecessary-condition
Remove unnecessary condition of RDoc::TokenStream.to_html
2 parents fbae5be + adbc9df commit fff6970

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

lib/rdoc/token_stream.rb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,8 @@ def self.to_html token_stream
2323
when :on_ivar then 'ruby-ivar'
2424
when :on_cvar then 'ruby-identifier'
2525
when :on_gvar then 'ruby-identifier'
26-
when '=' != t[:text] && :on_op then
27-
if RDoc::RipperStateLex::EXPR_ARG == t[:state] then
28-
'ruby-identifier'
29-
else
30-
'ruby-operator'
31-
end
26+
when '=' != t[:text] && :on_op
27+
then 'ruby-operator'
3228
when :on_tlambda then 'ruby-operator'
3329
when :on_ident then 'ruby-identifier'
3430
when :on_label then 'ruby-value'

test/test_rdoc_parser_ruby.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2674,6 +2674,29 @@ def blah()
26742674
assert_equal expected, markup_code
26752675
end
26762676

2677+
def test_parse_instance_operation_method
2678+
util_parser <<-RUBY
2679+
class Foo
2680+
def self.& end
2681+
end
2682+
RUBY
2683+
2684+
expected = <<EXPECTED
2685+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">&amp;</span> <span class="ruby-keyword">end</span>
2686+
<span class="ruby-keyword">end</span>
2687+
EXPECTED
2688+
expected = expected.rstrip
2689+
2690+
@parser.scan
2691+
2692+
foo = @top_level.classes.first
2693+
assert_equal 'Foo', foo.full_name
2694+
2695+
blah = foo.method_list.first
2696+
markup_code = blah.markup_code.sub(/^.*\n/, '')
2697+
assert_equal expected, markup_code
2698+
end
2699+
26772700
def test_parse_statements_postfix_if_after_heredocbeg
26782701
@filename = 'file.rb'
26792702
util_parser <<RUBY

0 commit comments

Comments
 (0)