File: test-parser-util.rb

package info (click to toggle)
rdtool 0.6.22-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 724 kB
  • ctags: 1,162
  • sloc: ruby: 8,017; lisp: 347; makefile: 55; sh: 30
file content (41 lines) | stat: -rwxr-xr-x 1,015 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
require 'test/unit'

require 'rd/rdblockparser.tab'
require 'rd/rd-struct'

include RD

class TestParserUtil < Test::Unit::TestCase
  def setup
    @p = RDParser.new
    @tree = tree = Tree.new_with_document_struct(DocumentStructure::RD)
    @p.instance_eval do
      @tree = tree
    end
  end

  def test_tree
    obj = Object.new
    obj.extend(ParserUtility)

    assert_raises(NotImplementedError) do
      obj.tree
    end
  end

  def test_add_children_to_element
    headline = Headline.new(1)
    string_element = StringElement.new "string"
    emphasis = Emphasis.new
    @p.add_children_to_element(headline, string_element, emphasis)
    assert_equal([string_element, emphasis], headline.children)

    textblock = TextBlock.new
    @p.add_children_to_element(textblock, emphasis, string_element)
    assert_equal([emphasis, string_element], textblock.children)

    textblock_empty = TextBlock.new
    @p.add_children_to_element(textblock_empty)
    assert_equal([], textblock_empty.children)
  end
end