2015-12-16 00:07:31 -05:00
|
|
|
# frozen_string_literal: false
|
2012-11-26 23:28:14 -05:00
|
|
|
require 'rdoc/test_case'
|
2003-12-01 02:12:49 -05:00
|
|
|
|
2012-11-26 23:28:14 -05:00
|
|
|
class TestRDocMarkup < RDoc::TestCase
|
|
|
|
|
|
|
|
def test_class_parse
|
|
|
|
expected = @RM::Document.new(
|
|
|
|
@RM::Paragraph.new('hello'))
|
|
|
|
|
|
|
|
assert_equal expected, RDoc::Markup.parse('hello')
|
|
|
|
end
|
2003-12-01 02:12:49 -05:00
|
|
|
|
2010-04-01 03:45:16 -04:00
|
|
|
def test_convert
|
|
|
|
str = <<-STR
|
|
|
|
now is
|
|
|
|
the time
|
2003-12-01 02:12:49 -05:00
|
|
|
|
2010-04-01 03:45:16 -04:00
|
|
|
hello
|
|
|
|
dave
|
2003-12-01 02:12:49 -05:00
|
|
|
|
2010-04-01 03:45:16 -04:00
|
|
|
1. l1
|
|
|
|
2. l2
|
|
|
|
STR
|
2003-12-01 02:12:49 -05:00
|
|
|
|
2008-02-09 22:59:08 -05:00
|
|
|
m = RDoc::Markup.new
|
2011-06-16 00:59:24 -04:00
|
|
|
|
|
|
|
tt = RDoc::Markup::ToTest.new m
|
|
|
|
|
|
|
|
out = m.convert str, tt
|
2010-04-01 03:45:16 -04:00
|
|
|
|
|
|
|
expected = [
|
|
|
|
"now is the time",
|
|
|
|
"\n",
|
|
|
|
" hello\n dave\n",
|
|
|
|
"1: ",
|
|
|
|
"l1",
|
|
|
|
"1: ",
|
|
|
|
"l2",
|
2008-02-09 22:59:08 -05:00
|
|
|
]
|
2003-12-01 02:12:49 -05:00
|
|
|
|
2010-04-01 03:45:16 -04:00
|
|
|
assert_equal expected, out
|
2003-12-01 02:12:49 -05:00
|
|
|
end
|
|
|
|
|
2011-06-16 00:59:24 -04:00
|
|
|
def test_convert_custom_markup
|
|
|
|
str = <<-STR
|
|
|
|
{stricken}
|
|
|
|
STR
|
|
|
|
|
|
|
|
m = RDoc::Markup.new
|
|
|
|
m.add_word_pair '{', '}', :STRIKE
|
|
|
|
|
2012-11-26 23:28:14 -05:00
|
|
|
tt = RDoc::Markup::ToTest.new nil, m
|
2011-06-16 00:59:24 -04:00
|
|
|
tt.add_tag :STRIKE, 'STRIKE ', ' STRIKE'
|
|
|
|
|
|
|
|
out = m.convert str, tt
|
|
|
|
|
|
|
|
expected = [
|
|
|
|
"STRIKE stricken STRIKE",
|
|
|
|
]
|
|
|
|
|
|
|
|
assert_equal expected, out
|
|
|
|
end
|
|
|
|
|
2011-06-27 22:28:25 -04:00
|
|
|
def test_convert_document
|
|
|
|
doc = RDoc::Markup::Parser.parse <<-STR
|
|
|
|
now is
|
|
|
|
the time
|
|
|
|
|
|
|
|
hello
|
|
|
|
dave
|
|
|
|
|
|
|
|
1. l1
|
|
|
|
2. l2
|
|
|
|
STR
|
|
|
|
|
|
|
|
m = RDoc::Markup.new
|
|
|
|
|
|
|
|
tt = RDoc::Markup::ToTest.new m
|
|
|
|
|
|
|
|
out = m.convert doc, tt
|
|
|
|
|
|
|
|
expected = [
|
|
|
|
"now is the time",
|
|
|
|
"\n",
|
|
|
|
" hello\n dave\n",
|
|
|
|
"1: ",
|
|
|
|
"l1",
|
|
|
|
"1: ",
|
|
|
|
"l2",
|
|
|
|
]
|
|
|
|
|
|
|
|
assert_equal expected, out
|
|
|
|
end
|
|
|
|
|
2003-12-01 02:12:49 -05:00
|
|
|
end
|
2007-12-28 01:13:06 -05:00
|
|
|
|