Skip to content

Commit 94dc242

Browse files
committed
Add test_class_tokenize_backtick_with_escape
1 parent cdf6bf6 commit 94dc242

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

test/test_rdoc_ruby_lex.rb

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,51 @@ def test_class_tokenize_string
350350
assert_equal expected, tokens
351351
end
352352

353+
def test_class_tokenize_backtick_with_escape
354+
tokens = RDoc::RubyLex.tokenize <<'RUBY', nil
355+
[
356+
`\\`,
357+
`\'\"\``,
358+
`\#`,
359+
`\#{}`,
360+
`#`,
361+
`#{}`
362+
]
363+
RUBY
364+
365+
expected = [
366+
@TK::TkLBRACK .new( 0, 1, 0, "["),
367+
@TK::TkNL .new( 1, 1, 1, "\n"),
368+
@TK::TkSPACE .new( 2, 2, 0, " "),
369+
@TK::TkXSTRING .new( 4, 2, 2, "`\\\\`"),
370+
@TK::TkCOMMA .new( 8, 2, 6, ","),
371+
@TK::TkNL .new( 9, 2, 2, "\n"),
372+
@TK::TkSPACE .new(10, 3, 0, " "),
373+
@TK::TkXSTRING .new(12, 3, 2, "`\\'\\\"\\``"),
374+
@TK::TkCOMMA .new(20, 3, 10, ","),
375+
@TK::TkNL .new(21, 3, 10, "\n"),
376+
@TK::TkSPACE .new(22, 4, 0, " "),
377+
@TK::TkXSTRING .new(24, 4, 2, "`\\#`"),
378+
@TK::TkCOMMA .new(28, 4, 6, ","),
379+
@TK::TkNL .new(29, 4, 22, "\n"),
380+
@TK::TkSPACE .new(30, 5, 0, " "),
381+
@TK::TkXSTRING .new(32, 5, 2, "`\\\#{}`"),
382+
@TK::TkCOMMA .new(38, 5, 8, ","),
383+
@TK::TkNL .new(39, 5, 30, "\n"),
384+
@TK::TkSPACE .new(40, 6, 0, " "),
385+
@TK::TkXSTRING .new(42, 6, 2, "`#`"),
386+
@TK::TkCOMMA .new(45, 6, 5, ","),
387+
@TK::TkNL .new(46, 6, 40, "\n"),
388+
@TK::TkSPACE .new(47, 7, 0, " "),
389+
@TK::TkDXSTRING.new(49, 7, 2, "`\#{}`"),
390+
@TK::TkNL .new(54, 7, 7, "\n"),
391+
@TK::TkRBRACK .new(55, 8, 0, "]"),
392+
@TK::TkNL .new(56, 8, 55, "\n")
393+
]
394+
395+
assert_equal expected, tokens
396+
end
397+
353398
def test_class_tokenize_string_escape
354399
tokens = RDoc::RubyLex.tokenize '"\\n"', nil
355400
assert_equal @TK::TkSTRING.new( 0, 1, 0, "\"\\n\""), tokens.first

0 commit comments

Comments
 (0)