1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test/rdoc/test_rdoc_rd_inline_parser.rb
drbrain df7dac9174 * lib/rdoc: Update to RDoc 4.1.0.preview.1
RDoc 4.1.0 contains a number of enhancements including a new default
  style and accessibility support.  You can see the changelog here:

  https://github.com/rdoc/rdoc/blob/v4.1.0.preview.1/History.rdoc

* test/rdoc:  ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42971 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-18 23:33:36 +00:00

177 lines
4.5 KiB
Ruby

require 'rdoc/test_case'
class TestRDocRdInlineParser < RDoc::TestCase
def setup
super
@block_parser = RDoc::RD::BlockParser.new
@block_parser.instance_variable_set :@i, 0
@inline_parser = RDoc::RD::InlineParser.new @block_parser
end
def test_parse
assert_equal 'regular <em>emphasis</em>', parse('regular ((*emphasis*))')
end
def test_parse_code
assert_equal '<code>text</code>', parse('(({text}))')
end
def test_parse_em
assert_equal '<em>text</em>', parse('((*text*))')
end
def test_parse_footnote
assert_equal '{*1}[rdoc-label:foottext-1:footmark-1]', parse('((-text-))')
expected = [
@RM::Paragraph.new('{^1}[rdoc-label:footmark-1:foottext-1]', ' ', 'text'),
blank_line,
]
assert_equal expected, @block_parser.footnotes
end
def test_parse_index
assert_equal '<span id="label-text">text</span>', parse('((:text:))')
assert_includes @block_parser.labels, 'text'
end
def test_parse_kbd
assert_equal '<tt>text</tt>', parse('((%text%))')
end
def test_parse_multiple
assert_equal '<em>one</em> <em>two</em>', parse('((*one*)) ((*two*))')
end
def test_parse_newline
assert_equal "one\ntwo", parse("one\ntwo")
end
def test_parse_quote
assert_equal 'one " two', parse('one " two')
end
def test_parse_ref
assert_equal '{text}[rdoc-label:text]', parse('((<text>))')
end
def test_parse_ref_em
assert_equal '{<em>text</em>}[rdoc-label:text]', parse('((<((*text*))>))')
end
def test_parse_ref_filename_quote
assert_equal '{RD/foo}[rdoc-label:RD/foo]', parse('((<RD/"foo">))')
end
def test_parse_ref_filename
assert_equal '{RD}[rdoc-label:RD/]', parse('((<RD/>))')
end
def test_parse_ref_quote
assert_equal '{text \\"}[rdoc-label:text \\"]', parse('((<text \">))')
end
def test_parse_ref_quote_content
assert_equal '{<em>text</em>}[rdoc-label:text]',
parse('((<"((*text*))">))')
end
def test_parse_ref_quote_content_multi
assert_equal '{<em>one</em> <em>two</em>}[rdoc-label:one two]',
parse('((<"((*one*)) ((*two*))">))')
end
def test_parse_ref_substitute
assert_equal '{text}[rdoc-label:thing]', parse('((<text|thing>))')
end
def test_parse_ref_substitute_element_quote
assert_equal '{text}[rdoc-label:"RD"]',
parse('((<text|"RD">))')
end
def test_parse_ref_substitute_filename
assert_equal '{text}[rdoc-label:RD/]', parse('((<text|RD/>))')
end
def test_parse_ref_substitute_filename_label
assert_equal '{text}[rdoc-label:RD/label]',
parse('((<text|RD/label>))')
end
def test_parse_ref_substitute_filename_quote
assert_equal '{text}[rdoc-label:"RD"/]', parse('((<text|"RD"/>))')
end
def test_parse_ref_substitute_multi_content
assert_equal '{<em>one</em> two}[rdoc-label:thing]',
parse('((<((*one*)) two|thing>))')
end
def test_parse_ref_substitute_multi_content2
assert_equal '{<em>one</em> \\" two}[rdoc-label:thing]',
parse('((<((*one*)) \" two|thing>))')
end
def test_parse_ref_substitute_multi_content3
assert_equal '{<em>one</em> \\" <em>two</em>}[rdoc-label:thing]',
parse('((<((*one*)) \" ((*two*))|thing>))')
end
def test_parse_ref_substitute_quote
assert_equal '{one | two}[rdoc-label:thing]',
parse('((<"one | two"|thing>))')
end
def test_parse_ref_substitute_quote_content
assert_equal '{<em>text</em>}[rdoc-label:thing]',
parse('((<"((*text*))"|thing>))')
end
def test_parse_ref_substitute_url
assert_equal '{text}[http://example]',
parse('((<text|URL:http://example>))')
end
def test_parse_ref_url
assert_equal '{http://example}[http://example]',
parse('((<URL:http://example>))')
end
def test_parse_var
assert_equal '+text+', parse('((|text|))')
end
def test_parse_verb
assert_equal '<tt>text</tt>', parse("(('text'))")
end
def test_parse_verb_backslash
assert_equal "<tt>(('text'))</tt>", parse("(('(('text\\'))'))")
end
def test_parse_verb_backslash_backslash
assert_equal '<tt>text \\</tt>', parse("(('text \\\\'))")
end
def test_parse_verb_backslash_quote
assert_equal '<tt>text "</tt>', parse("(('text \\\"'))")
end
def test_parse_verb_emphasis
assert_equal '<tt>((*emphasis*))</tt>', parse("(('((*emphasis*))'))")
end
def test_parse_verb_multiple
assert_equal '<tt>((*text*))</tt>', parse("(('((*text*))'))")
end
def parse text
@inline_parser.parse text
end
end