Skip to content

Commit b096046

Browse files
committed
Add test_accept_verbatim_escape_in_string
1 parent 3364622 commit b096046

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

test/test_rdoc_markup_to_html.rb

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,66 @@ def test_accept_verbatim_pipe
469469
assert_equal expected, @to.res.join
470470
end
471471

472+
def test_accept_verbatim_escape_in_string
473+
code = <<-'RUBY'
474+
def foo
475+
[
476+
'\\',
477+
'\'',
478+
"'",
479+
"\'\"\`",
480+
"\#",
481+
"\#{}",
482+
"#",
483+
"#{}",
484+
/'"/,
485+
/\'\"/,
486+
/\//,
487+
/\\/,
488+
/\#/,
489+
/\#{}/,
490+
/#/,
491+
/#{}/
492+
]
493+
end
494+
def bar
495+
end
496+
RUBY
497+
verb = @RM::Verbatim.new(*code.split(/(?<=\n)/))
498+
499+
@to.start_accepting
500+
@to.accept_verbatim verb
501+
502+
expected = <<-'EXPECTED'
503+
504+
<pre class="ruby"><span class="ruby-keyword">def</span> <span class="ruby-identifier">foo</span>
505+
[
506+
<span class="ruby-string">&#39;\\&#39;</span>,
507+
<span class="ruby-string">&#39;\&#39;&#39;</span>,
508+
<span class="ruby-string">&quot;&#39;&quot;</span>,
509+
<span class="ruby-string">&quot;\&#39;\&quot;\`&quot;</span>,
510+
<span class="ruby-string">&quot;\#&quot;</span>,
511+
<span class="ruby-string">&quot;\#{}&quot;</span>,
512+
<span class="ruby-string">&quot;#&quot;</span>,
513+
<span class="ruby-node">&quot;#{}&quot;</span>,
514+
<span class="ruby-regexp">/&#39;&quot;/</span>,
515+
<span class="ruby-regexp">/\&#39;\&quot;/</span>,
516+
<span class="ruby-regexp">/\//</span>,
517+
<span class="ruby-regexp">/\\/</span>,
518+
<span class="ruby-regexp">/\#/</span>,
519+
<span class="ruby-regexp">/\#{}/</span>,
520+
<span class="ruby-regexp">/#/</span>,
521+
<span class="ruby-regexp">/#{}/</span>
522+
]
523+
<span class="ruby-keyword">end</span>
524+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">bar</span>
525+
<span class="ruby-keyword">end</span>
526+
</pre>
527+
EXPECTED
528+
529+
assert_equal expected, @to.res.join
530+
end
531+
472532
def test_accept_verbatim_ruby
473533
verb = @RM::Verbatim.new("1 + 1\n")
474534
verb.format = :ruby

0 commit comments

Comments
 (0)