diff options
Diffstat (limited to 'test/rdoc/test_attribute_manager.rb')
-rw-r--r-- | test/rdoc/test_attribute_manager.rb | 69 |
1 files changed, 52 insertions, 17 deletions
diff --git a/test/rdoc/test_attribute_manager.rb b/test/rdoc/test_attribute_manager.rb index e908b86b02..25e8ca5e04 100644 --- a/test/rdoc/test_attribute_manager.rb +++ b/test/rdoc/test_attribute_manager.rb @@ -2,29 +2,35 @@ require 'rubygems' require 'minitest/autorun' require 'rdoc' require 'rdoc/markup' +require 'rdoc/markup/formatter' require 'rdoc/markup/attribute_manager' -class TestAttributeManager < MiniTest::Unit::TestCase +class TestAttributeManager < MiniTest::Unit::TestCase # HACK fix test name def setup @am = RDoc::Markup::AttributeManager.new @klass = RDoc::Markup::AttributeManager + @formatter = RDoc::Markup::Formatter.new + @formatter.add_tag :BOLD, '<B>', '</B>' + @formatter.add_tag :EM, '<EM>', '</EM>' + @formatter.add_tag :TT, '<TT>', '</TT>' end def test_convert_attrs_ignores_code - collector = RDoc::Markup::AttrSpan.new 10 - str = 'foo <code>__send__</code> bar' - @am.convert_html str, collector - @am.convert_attrs str, collector - assert_match(/__send__/, str) + assert_equal 'foo <TT>__send__</TT> bar', output('foo <code>__send__</code> bar') end def test_convert_attrs_ignores_tt - collector = RDoc::Markup::AttrSpan.new 10 - str = 'foo <tt>__send__</tt> bar' - @am.convert_html str, collector - @am.convert_attrs str, collector - assert_match(/__send__/, str) + assert_equal 'foo <TT>__send__</TT> bar', output('foo <tt>__send__</tt> bar') + end + + def test_convert_attrs_preserves_double + assert_equal 'foo.__send__ :bar', output('foo.__send__ :bar') + assert_equal 'use __FILE__ to', output('use __FILE__ to') + end + + def test_convert_attrs_does_not_ignore_after_tt + assert_equal 'the <TT>IF:</TT><EM>key</EM> directive', output('the <tt>IF:</tt>_key_ directive') end def test_initial_word_pairs @@ -73,12 +79,41 @@ class TestAttributeManager < MiniTest::Unit::TestCase assert(specials.has_key?("WikiWord")) end - def silently(&block) - warn_level = $VERBOSE - $VERBOSE = nil - result = block.call - $VERBOSE = warn_level - result + def test_escapes + assert_equal '<TT>text</TT>', output('<tt>text</tt>') + assert_equal '<tt>text</tt>', output('\\<tt>text</tt>') + assert_equal '<tt>', output('\\<tt>') + assert_equal '<TT><tt></TT>', output('<tt>\\<tt></tt>') + assert_equal '<TT>\\<tt></TT>', output('<tt>\\\\<tt></tt>') + assert_equal '<B>text</B>', output('*text*') + assert_equal '*text*', output('\\*text*') + assert_equal '\\', output('\\') + assert_equal '\\text', output('\\text') + assert_equal '\\\\text', output('\\\\text') + assert_equal 'text \\ text', output('text \\ text') + + assert_equal 'and <TT>\\s</TT> matches space', + output('and <tt>\\s</tt> matches space') + assert_equal 'use <TT><tt>text</TT></tt> for code', + output('use <tt>\\<tt>text</tt></tt> for code') + assert_equal 'use <TT><tt>text</tt></TT> for code', + output('use <tt>\\<tt>text\\</tt></tt> for code') + assert_equal 'use <tt><tt>text</tt></tt> for code', + output('use \\<tt>\\<tt>text</tt></tt> for code') + assert_equal 'use <tt><TT>text</TT></tt> for code', + output('use \\<tt><tt>text</tt></tt> for code') + assert_equal 'use <TT>+text+</TT> for code', + output('use <tt>\\+text+</tt> for code') + assert_equal 'use <tt><TT>text</TT></tt> for code', + output('use \\<tt>+text+</tt> for code') + assert_equal 'illegal <tag>not</tag> changed', + output('illegal <tag>not</tag> changed') + assert_equal 'unhandled <p>tag</p> unchanged', + output('unhandled <p>tag</p> unchanged') + end + + def output str + @formatter.convert_flow @am.flow str end end |