2008-10-24 19:05:28 -04:00
|
|
|
require 'rubygems'
|
2010-04-01 03:45:16 -04:00
|
|
|
require 'minitest/autorun'
|
2008-01-18 19:06:19 -05:00
|
|
|
require 'rdoc/markup'
|
|
|
|
require 'rdoc/markup/to_test'
|
2003-12-01 02:12:49 -05:00
|
|
|
|
2008-10-24 19:05:28 -04:00
|
|
|
class TestRDocMarkup < MiniTest::Unit::TestCase
|
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
|
|
|
|
|
|
|
|
tt = RDoc::Markup::ToTest.new m
|
|
|
|
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
|
|
|
|