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-textblock.rb < prev    next >
Text File  |  2001-03-29  |  1KB  |  50 lines

  1. require 'runit/testcase'
  2. require 'runit/cui/mytestrunner'
  3.  
  4. require 'rd/block-element'
  5. require 'rd/inline-element'
  6. require 'rd/rd-struct'
  7.  
  8. include RD
  9.  
  10. class TestTextBlock < RUNIT::TestCase
  11.   def setup
  12.     @p = TextBlock.new
  13.     @c1 = StringElement.new "string"
  14.     @c2 = Emphasis.new
  15.     @c21 = StringElement.new "in emphasis"
  16.     @c2.add_child_under_document_struct(@c21, DocumentStructure::RD)
  17.     @c3 = Code.new
  18.     @c31 = StringElement.new "code"
  19.     @c32 = Var.new
  20.     @c321 = StringElement.new "var"
  21.     @c32.add_child_under_document_struct(@c321, DocumentStructure::RD)
  22.     @c3.add_children_under_document_struct([@c31, @c32], DocumentStructure::RD)
  23.     @c4 = Verb.new "verb"
  24.     @p.add_children_under_document_struct([@c1, @c2, @c3, @c4],
  25.                       DocumentStructure::RD)
  26.   end
  27.  
  28.   def test_each_child
  29.     exp = [@c1, @c2, @c3, @c4]
  30.     i = 0
  31.     @p.each_child do |b|
  32.       assert_equal(exp[i], b)
  33.       i += 1
  34.     end
  35.   end
  36.  
  37.   def test_each_element
  38.     exp = [@p, @c1, @c2, @c21, @c3, @c31, @c32, @c321, @c4]
  39.     i = 0
  40.     @p.each_element do |b|
  41.       assert_equal(exp[i], b)
  42.       i += 1
  43.     end
  44.   end
  45. end
  46.   
  47. if $0 == __FILE__
  48.   RUNIT::CUI::MyTestRunner.run(TestTextBlock.suite)
  49. end
  50.