Sha256: 8ba190aa08d973750aaeaba6680419540939848cd3a5d24b9922bab91e105881

Contents?: true

Size: 1.54 KB

Versions: 24

Compression:

Stored size: 1.54 KB

Contents

require 'test/unit'

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

include RD

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

    @inline_parser = RDInlineParser.new(@block_parser)
  end

  def test_tree
    assert_equal(@tree, @inline_parser.tree)
  end

  def test_make_reference_from_label
    label = Reference::TemporaryLabel.new([StringElement.new("label")])
    expect = Reference.new_from_label_under_document_struct(label,
                        DocumentStructure::RD)
    ref = @inline_parser.make_reference_from_label(label)
    assert_equal(expect.label.element_label, ref.label.element_label)
    assert_equal(expect.label.filename, ref.label.filename)
  end

  def test_prev_words_on_error
    @inline_parser.instance_eval{@pre="foo bar baz"}
    assert_equal("foo bar baz", @inline_parser.prev_words_on_error("foo"))
    assert_equal("foo bar ", @inline_parser.prev_words_on_error("baz"))
    assert_equal("foo bar baz", @inline_parser.prev_words_on_error(false))
    assert_equal("foo bar baz", @inline_parser.prev_words_on_error("not exist"))
    @inline_parser.instance_eval{@pre="foo bar\nfoo2 bar2"}
    assert_equal("foo2 bar2", @inline_parser.prev_words_on_error("foo2"))
    assert_equal("foo2 ", @inline_parser.prev_words_on_error("bar2"))

    @inline_parser.instance_eval{@pre="foo?"}
    assert_equal("foo", @inline_parser.prev_words_on_error("?"))
  end
end

Version data entries

24 entries across 23 versions & 2 rubygems

Version Path
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/rdtool-0.6.38/test/test-inline-parser.rb
tdiary-5.0.8 vendor/bundle/gems/rdtool-0.6.38/test/test-inline-parser.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/rdtool-0.6.38/test/test-inline-parser.rb
tdiary-5.0.5 vendor/bundle/gems/rdtool-0.6.38/test/test-inline-parser.rb
tdiary-5.0.4 vendor/bundle/gems/rdtool-0.6.38/test/test-inline-parser.rb
tdiary-4.2.1 vendor/bundle/ruby/2.2.0/gems/rdtool-0.6.38/test/test-inline-parser.rb
tdiary-3.2.2.20130518 vendor/rdtool-0.6.38/test/test-inline-parser.rb
tdiary-3.2.2.20130508 vendor/rdtool-0.6.38/test/test-inline-parser.rb
tdiary-3.2.2.20130507 vendor/rdtool-0.6.38/test/test-inline-parser.rb
rdtool-0.6.38 test/test-inline-parser.rb
rdtool-0.6.37 test/test-inline-parser.rb
rdtool-0.6.36 test/test-inline-parser.rb
rdtool-0.6.35 test/test-inline-parser.rb
rdtool-0.6.34 test/test-inline-parser.rb
rdtool-0.6.33 test/test-inline-parser.rb
rdtool-0.6.32 test/test-inline-parser.rb
rdtool-0.6.31 test/test-inline-parser.rb
rdtool-0.6.30 test/test-inline-parser.rb
rdtool-0.6.29 test/test-inline-parser.rb
rdtool-0.6.28 test/test-inline-parser.rb