2008-10-24 19:05:28 -04:00
|
|
|
require 'rubygems'
|
2010-04-01 03:45:16 -04:00
|
|
|
require 'minitest/autorun'
|
|
|
|
require 'rdoc'
|
|
|
|
require 'rdoc/markup'
|
2008-09-24 22:43:03 -04:00
|
|
|
require 'rdoc/markup/attribute_manager'
|
|
|
|
|
2008-10-24 19:05:28 -04:00
|
|
|
class TestAttributeManager < MiniTest::Unit::TestCase
|
2008-09-24 22:43:03 -04:00
|
|
|
|
|
|
|
def setup
|
|
|
|
@am = RDoc::Markup::AttributeManager.new
|
|
|
|
@klass = RDoc::Markup::AttributeManager
|
|
|
|
end
|
2008-10-24 19:05:28 -04:00
|
|
|
|
2008-09-24 22:43:03 -04:00
|
|
|
def test_initial_word_pairs
|
2010-04-01 03:45:16 -04:00
|
|
|
word_pairs = @am.matching_word_pairs
|
2008-09-24 22:43:03 -04:00
|
|
|
assert word_pairs.is_a?(Hash)
|
|
|
|
assert_equal(3, word_pairs.size)
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_initial_html
|
2010-04-01 03:45:16 -04:00
|
|
|
html_tags = @am.html_tags
|
2008-09-24 22:43:03 -04:00
|
|
|
assert html_tags.is_a?(Hash)
|
|
|
|
assert_equal(5, html_tags.size)
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_add_matching_word_pair
|
|
|
|
@am.add_word_pair("x","x", :TEST)
|
2010-04-01 03:45:16 -04:00
|
|
|
word_pairs = @am.matching_word_pairs
|
2008-09-24 22:43:03 -04:00
|
|
|
assert_equal(4,word_pairs.size)
|
|
|
|
assert(word_pairs.has_key?("x"))
|
|
|
|
end
|
2008-10-24 19:05:28 -04:00
|
|
|
|
2008-09-24 22:43:03 -04:00
|
|
|
def test_add_invalid_word_pair
|
2008-10-24 19:05:28 -04:00
|
|
|
assert_raises ArgumentError do
|
2008-09-24 22:43:03 -04:00
|
|
|
@am.add_word_pair("<", "<", :TEST)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_add_word_pair_map
|
|
|
|
@am.add_word_pair("x", "y", :TEST)
|
2010-04-01 03:45:16 -04:00
|
|
|
word_pair_map = @am.word_pair_map
|
2008-09-24 22:43:03 -04:00
|
|
|
assert_equal(1,word_pair_map.size)
|
|
|
|
assert_equal(word_pair_map. keys.first.source, "(x)(\\S+)(y)")
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_add_html_tag
|
|
|
|
@am.add_html("Test", :TEST)
|
2010-04-01 03:45:16 -04:00
|
|
|
tags = @am.html_tags
|
2008-09-24 22:43:03 -04:00
|
|
|
assert_equal(6, tags.size)
|
|
|
|
assert(tags.has_key?("test"))
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_add_special
|
|
|
|
@am.add_special("WikiWord", :WIKIWORD)
|
2010-04-01 03:45:16 -04:00
|
|
|
specials = @am.special
|
2008-09-24 22:43:03 -04:00
|
|
|
assert_equal(1,specials.size)
|
|
|
|
assert(specials.has_key?("WikiWord"))
|
|
|
|
end
|
|
|
|
|
|
|
|
def silently(&block)
|
|
|
|
warn_level = $VERBOSE
|
|
|
|
$VERBOSE = nil
|
|
|
|
result = block.call
|
|
|
|
$VERBOSE = warn_level
|
|
|
|
result
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2008-10-24 19:05:28 -04:00
|
|
|
|