home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ruby164.zip / rbemx164.zip / ruby / share / doc / rdtool-0.6.10 / test / test-parser-util.rb < prev    next >
Text File  |  2001-05-02  |  1KB  |  49 lines

  1. require 'runit/testcase'
  2. require 'runit/cui/mytestrunner'
  3. require 'runit/topublic'
  4.  
  5. require 'rd/rdblockparser.tab'
  6. require 'rd/rd-struct'
  7.  
  8. include RD
  9.  
  10. class TestParserUtil < RUNIT::TestCase
  11.   include RUNIT::ToPublic
  12.   def setup
  13.     @p = to_public(RDParser).new
  14.     @tree = tree = Tree.new_with_document_struct(DocumentStructure::RD)
  15.     @p.instance_eval do
  16.       @tree = tree
  17.     end
  18.   end
  19.  
  20.   def test_tree
  21.     obj = Object.new
  22.     obj.extend(ParserUtility)
  23.  
  24.     assert_exception(NotImplementedError) do
  25.       obj.tree
  26.     end
  27.   end
  28.  
  29.   def test_add_children_to_element
  30.     headline = to_public(Headline).new(1)
  31.     string_element = StringElement.new "string"
  32.     emphasis = Emphasis.new
  33.     @p.add_children_to_element(headline, string_element, emphasis)
  34.     assert_equal([string_element, emphasis], headline.children)
  35.  
  36.     textblock = to_public(TextBlock).new
  37.     @p.add_children_to_element(textblock, emphasis, string_element)
  38.     assert_equal([emphasis, string_element], textblock.children)
  39.  
  40.     textblock_empty = to_public(TextBlock).new
  41.     @p.add_children_to_element(textblock_empty)
  42.     assert_equal([], textblock_empty.children)
  43.   end
  44. end
  45.  
  46. if $0 == __FILE__
  47.   RUNIT::CUI::TestRunner.run(TestParserUtil.suite)
  48. end
  49.