~ubuntu-branches/ubuntu/quantal/ruby1.9.1/quantal

« back to all changes in this revision

Viewing changes to test/rdoc/test_rdoc_context_section.rb

  • Committer: Bazaar Package Importer
  • Author(s): Lucas Nussbaum
  • Date: 2011-09-24 19:16:17 UTC
  • mfrom: (1.1.8 upstream) (13.1.7 experimental)
  • Revision ID: james.westby@ubuntu.com-20110924191617-o1qz4rcmqjot8zuy
Tags: 1.9.3~rc1-1
* New upstream release: 1.9.3 RC1.
  + Includes load.c fixes. Closes: #639959.
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require 'rubygems'
 
2
require 'cgi'
 
3
require 'minitest/autorun'
 
4
require 'rdoc'
 
5
require 'rdoc/code_objects'
 
6
 
 
7
class TestRDocContextSection < MiniTest::Unit::TestCase
 
8
 
 
9
  def setup
 
10
    @S = RDoc::Context::Section
 
11
    @s = @S.new nil, 'section', '# comment'
 
12
  end
 
13
 
 
14
  def test_aref
 
15
    assert_equal 'section', @s.aref
 
16
 
 
17
    assert_equal '5Buntitled-5D', @S.new(nil, nil, nil).aref
 
18
 
 
19
    assert_equal 'one+two', @S.new(nil, 'one two', nil).aref
 
20
  end
 
21
 
 
22
  def test_comment_equals
 
23
    @s.comment = "# :section: section\n"
 
24
 
 
25
    assert_equal "# comment", @s.comment
 
26
 
 
27
    @s.comment = "# :section: section\n# other"
 
28
 
 
29
    assert_equal "# comment\n# ---\n# other", @s.comment
 
30
 
 
31
    s = @S.new nil, nil, nil
 
32
 
 
33
    s.comment = "# :section:\n# other"
 
34
 
 
35
    assert_equal "# other", s.comment
 
36
  end
 
37
 
 
38
  def test_extract_comment
 
39
    assert_equal '',    @s.extract_comment('')
 
40
    assert_equal '',    @s.extract_comment("# :section: b\n")
 
41
    assert_equal '# c', @s.extract_comment("# :section: b\n# c")
 
42
    assert_equal '# c', @s.extract_comment("# a\n# :section: b\n# c")
 
43
  end
 
44
 
 
45
  def test_sequence
 
46
    _, err = capture_io do
 
47
      assert_match(/\ASEC\d{5}\Z/, @s.sequence)
 
48
    end
 
49
 
 
50
    assert_equal "#{@S}#sequence is deprecated, use #aref\n", err
 
51
  end
 
52
 
 
53
end
 
54