Skip to content

Commit 689c8a2

Browse files
committed
Add test_accept_verbatim_redefinable_operators
1 parent e45f7cd commit 689c8a2

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/test_rdoc_markup_to_html.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,36 @@ def test_accept_verbatim_ruby
485485
assert_equal expected, @to.res.join
486486
end
487487

488+
def test_accept_verbatim_redefinable_operators
489+
functions = %w[| ^ & <=> == === =~ > >= < <= << >> + - * / % ** ~ +@ -@ [] []= ` ! != !~].map { |redefinable_op|
490+
["def #{redefinable_op}\n", "end\n"]
491+
}.flatten
492+
493+
verb = @RM::Verbatim.new(*functions)
494+
495+
@to.start_accepting
496+
@to.accept_verbatim verb
497+
498+
expected = <<-EXPECTED
499+
500+
<pre class="ruby">
501+
EXPECTED
502+
expected = expected.rstrip
503+
504+
%w[| ^ &amp; &lt;=&gt; == === =~ &gt; &gt;= &lt; &lt;= &lt;&lt; &gt;&gt; + - * / % ** ~ +@ -@ [] []= ` ! != !~].each do |html_escaped_op|
505+
expected += <<-EXPECTED
506+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">#{html_escaped_op}</span>
507+
<span class="ruby-keyword">end</span>
508+
EXPECTED
509+
end
510+
511+
expected += <<-EXPECTED
512+
</pre>
513+
EXPECTED
514+
515+
assert_equal expected, @to.res.join
516+
end
517+
488518
def test_convert_string
489519
assert_equal '&lt;&gt;', @to.convert_string('<>')
490520
end

0 commit comments

Comments
 (0)