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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
require 'rubygems'
require 'minitest/autorun'
require 'rdoc/rdoc'
require 'rdoc/code_objects'
require 'rdoc/markup/to_html_crossref'
require File.expand_path '../xref_test_case', __FILE__
class TestRDocMarkupToHtmlCrossref < XrefTestCase
def setup
super
@to = RDoc::Markup::ToHtmlCrossref.new 'index.html', @c1, true
end
def test_convert_CROSSREF
result = @to.convert 'C1'
assert_equal "\n<p><a href=\"C1.html\">C1</a></p>\n", result
end
def test_convert_HYPERLINK_rdoc_ref
result = @to.convert 'rdoc-ref:C1'
assert_equal "\n<p><a href=\"C1.html\">C1</a></p>\n", result
end
def test_convert_TIDYLINK_rdoc_ref
result = @to.convert '{foo}[rdoc-ref:C1]'
assert_equal "\n<p><a href=\"C1.html\">foo</a></p>\n", result
end
def test_gen_url
assert_equal '<a href="C1.html">Some class</a>',
@to.gen_url('rdoc-ref:C1', 'Some class')
assert_equal '<a href="http://example">HTTP example</a>',
@to.gen_url('http://example', 'HTTP example')
end
def test_handle_special_CROSSREF
assert_equal "<a href=\"C2/C3.html\">C2::C3</a>", SPECIAL('C2::C3')
end
def test_handle_special_CROSSREF_show_hash_false
@to.show_hash = false
assert_equal "<a href=\"C1.html#method-i-m\">m</a>",
SPECIAL('#m')
end
def test_handle_special_HYPERLINK_rdoc
RDoc::TopLevel.new 'README.txt'
@to = RDoc::Markup::ToHtmlCrossref.new 'C2.html', @c2, true
link = @to.handle_special_HYPERLINK hyper 'C2::C3'
assert_equal '<a href="C2/C3.html">C2::C3</a>', link
link = @to.handle_special_HYPERLINK hyper 'C4'
assert_equal '<a href="C4.html">C4</a>', link
link = @to.handle_special_HYPERLINK hyper 'README.txt'
assert_equal '<a href="README_txt.html">README.txt</a>', link
end
def test_handle_special_TIDYLINK_rdoc
RDoc::TopLevel.new 'README.txt'
@to = RDoc::Markup::ToHtmlCrossref.new 'C2.html', @c2, true
link = @to.handle_special_TIDYLINK tidy 'C2::C3'
assert_equal '<a href="C2/C3.html">tidy</a>', link
link = @to.handle_special_TIDYLINK tidy 'C4'
assert_equal '<a href="C4.html">tidy</a>', link
link = @to.handle_special_TIDYLINK tidy 'README.txt'
assert_equal '<a href="README_txt.html">tidy</a>', link
end
def test_link
assert_equal 'n', @to.link('n', 'n')
assert_equal '<a href="C1.html#method-c-m">m</a>', @to.link('m', 'm')
end
def SPECIAL text
@to.handle_special_CROSSREF special text
end
def hyper reference
RDoc::Markup::Special.new 0, "rdoc-ref:#{reference}"
end
def special text
RDoc::Markup::Special.new 0, text
end
def tidy reference
RDoc::Markup::Special.new 0, "{tidy}[rdoc-ref:#{reference}]"
end
end
|