summaryrefslogtreecommitdiff
path: root/test/rdoc/test_rdoc_parser_perl.rb
blob: 165cadaa5dc016b2b14cb13f743d33e58aa4208c (plain)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
require 'stringio'
require 'tempfile'
require 'rubygems'
require 'minitest/unit'
require 'rdoc/options'
require 'rdoc/parser/perl'

class TestRdocParserPerlPOD < MiniTest::Unit::TestCase

  def setup
    @tempfile = Tempfile.new self.class.name
    filename = @tempfile.path

    @top_level = RDoc::TopLevel.new filename
    @fn = filename
    @options = RDoc::Options.new
    @stats = RDoc::Stats.new 0
  end

  def teardown
    @tempfile.close
  end

  def test_uncommented_perl
    content = <<-EOF
while (<>) {
  tr/a-z/A-Z;
  print
}
    EOF

    comment =  util_get_comment content
    assert_equal "", comment
  end

  def test_perl_without_pod
    content = <<-EOF
#!/usr/local/bin/perl
#
#This is a pointless perl program because it does -p.
#
while(<>) {print;}:
    EOF

    comment = util_get_comment content
    assert_equal "", comment
  end

  def test_simple_pod_no_structure
    content = <<-EOF
=begin pod

This just contains plain old documentation

=end
    EOF
    comment = util_get_comment content
    assert_equal "\nThis just contains plain old documentation\n\n", comment
  end

  # Get the comment of the @top_level when it has processed the input.
  def util_get_comment(content)
    parser = util_parser content
    parser.scan.comment
  end

  # create a new parser with the supplied content.
  def util_parser(content)
    RDoc::Parser::PerlPOD.new @top_level, @fn, content, @options, @stats
  end

end

MiniTest::Unit.autorun