bitclust-core 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +2907 -0
- data/Gemfile +7 -0
- data/README +21 -0
- data/Rakefile +20 -0
- data/bin/bitclust +14 -0
- data/bin/refe +36 -0
- data/bitclust-dev.gemspec +33 -0
- data/bitclust.gemspec +30 -0
- data/config.in +23 -0
- data/config.ru +48 -0
- data/config.ru.sample +31 -0
- data/data/bitclust/catalog/ja_JP.EUC-JP +78 -0
- data/data/bitclust/catalog/ja_JP.UTF-8 +78 -0
- data/data/bitclust/template.lillia/class +98 -0
- data/data/bitclust/template.lillia/class-index +28 -0
- data/data/bitclust/template.lillia/doc +48 -0
- data/data/bitclust/template.lillia/layout +19 -0
- data/data/bitclust/template.lillia/library +129 -0
- data/data/bitclust/template.lillia/library-index +32 -0
- data/data/bitclust/template.lillia/method +20 -0
- data/data/bitclust/template.lillia/rd_file +6 -0
- data/data/bitclust/template.offline/class +67 -0
- data/data/bitclust/template.offline/class-index +28 -0
- data/data/bitclust/template.offline/doc +13 -0
- data/data/bitclust/template.offline/function +22 -0
- data/data/bitclust/template.offline/function-index +24 -0
- data/data/bitclust/template.offline/layout +18 -0
- data/data/bitclust/template.offline/library +87 -0
- data/data/bitclust/template.offline/library-index +32 -0
- data/data/bitclust/template.offline/method +21 -0
- data/data/bitclust/template.offline/rd_file +6 -0
- data/data/bitclust/template/class +133 -0
- data/data/bitclust/template/class-index +30 -0
- data/data/bitclust/template/doc +14 -0
- data/data/bitclust/template/function +21 -0
- data/data/bitclust/template/function-index +25 -0
- data/data/bitclust/template/layout +19 -0
- data/data/bitclust/template/library +89 -0
- data/data/bitclust/template/library-index +35 -0
- data/data/bitclust/template/method +24 -0
- data/data/bitclust/template/opensearchdescription +10 -0
- data/data/bitclust/template/search +57 -0
- data/lib/bitclust.rb +9 -0
- data/lib/bitclust/app.rb +129 -0
- data/lib/bitclust/classentry.rb +425 -0
- data/lib/bitclust/compat.rb +39 -0
- data/lib/bitclust/completion.rb +531 -0
- data/lib/bitclust/crossrubyutils.rb +91 -0
- data/lib/bitclust/database.rb +181 -0
- data/lib/bitclust/docentry.rb +83 -0
- data/lib/bitclust/entry.rb +223 -0
- data/lib/bitclust/exception.rb +38 -0
- data/lib/bitclust/functiondatabase.rb +115 -0
- data/lib/bitclust/functionentry.rb +81 -0
- data/lib/bitclust/functionreferenceparser.rb +76 -0
- data/lib/bitclust/htmlutils.rb +80 -0
- data/lib/bitclust/interface.rb +87 -0
- data/lib/bitclust/libraryentry.rb +211 -0
- data/lib/bitclust/lineinput.rb +165 -0
- data/lib/bitclust/messagecatalog.rb +95 -0
- data/lib/bitclust/methoddatabase.rb +401 -0
- data/lib/bitclust/methodentry.rb +202 -0
- data/lib/bitclust/methodid.rb +209 -0
- data/lib/bitclust/methodsignature.rb +82 -0
- data/lib/bitclust/nameutils.rb +236 -0
- data/lib/bitclust/parseutils.rb +60 -0
- data/lib/bitclust/preprocessor.rb +273 -0
- data/lib/bitclust/rdcompiler.rb +507 -0
- data/lib/bitclust/refsdatabase.rb +66 -0
- data/lib/bitclust/requesthandler.rb +330 -0
- data/lib/bitclust/ridatabase.rb +349 -0
- data/lib/bitclust/rrdparser.rb +522 -0
- data/lib/bitclust/runner.rb +143 -0
- data/lib/bitclust/screen.rb +554 -0
- data/lib/bitclust/searcher.rb +518 -0
- data/lib/bitclust/server.rb +59 -0
- data/lib/bitclust/simplesearcher.rb +84 -0
- data/lib/bitclust/subcommand.rb +746 -0
- data/lib/bitclust/textutils.rb +51 -0
- data/lib/bitclust/version.rb +3 -0
- data/packer.rb +224 -0
- data/refe2.gemspec +29 -0
- data/server.exe +0 -0
- data/server.exy +159 -0
- data/server.rb +10 -0
- data/setup.rb +1596 -0
- data/standalone.rb +193 -0
- data/test/run_test.rb +15 -0
- data/test/test_bitclust.rb +81 -0
- data/test/test_entry.rb +39 -0
- data/test/test_functiondatabase.rb +55 -0
- data/test/test_libraryentry.rb +31 -0
- data/test/test_methoddatabase.rb +81 -0
- data/test/test_methodsignature.rb +14 -0
- data/test/test_nameutils.rb +324 -0
- data/test/test_preprocessor.rb +84 -0
- data/test/test_rdcompiler.rb +534 -0
- data/test/test_refsdatabase.rb +76 -0
- data/test/test_rrdparser.rb +26 -0
- data/test/test_runner.rb +102 -0
- data/test/test_simplesearcher.rb +48 -0
- data/theme/default/images/external.png +0 -0
- data/theme/default/rurema.png +0 -0
- data/theme/default/style.css +288 -0
- data/theme/default/test.css +254 -0
- data/theme/lillia/rurema.png +0 -0
- data/theme/lillia/style.css +331 -0
- data/theme/lillia/test.css +254 -0
- data/tools/bc-ancestors.rb +153 -0
- data/tools/bc-checkparams.rb +246 -0
- data/tools/bc-classes.rb +80 -0
- data/tools/bc-convert.rb +165 -0
- data/tools/bc-list.rb +63 -0
- data/tools/bc-methods.rb +171 -0
- data/tools/bc-preproc.rb +42 -0
- data/tools/bc-rdoc.rb +343 -0
- data/tools/bc-tochm.rb +301 -0
- data/tools/bc-tohtml.rb +125 -0
- data/tools/bc-tohtmlpackage.rb +241 -0
- data/tools/check-signature.rb +19 -0
- data/tools/forall-ruby.rb +20 -0
- data/tools/gencatalog.rb +69 -0
- data/tools/statrefm.rb +98 -0
- data/tools/stattodo.rb +150 -0
- data/tools/update-database.rb +146 -0
- data/view.cgi +6 -0
- metadata +222 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require 'test/unit'
|
|
2
|
+
require 'bitclust/methodsignature'
|
|
3
|
+
|
|
4
|
+
class TestMethodSignature < Test::Unit::TestCase
|
|
5
|
+
|
|
6
|
+
def test_friendlyname
|
|
7
|
+
[
|
|
8
|
+
["$_ -> String | nil", "--- $_ -> String | nil"],
|
|
9
|
+
["`command` -> String", "--- `(command) -> String"],
|
|
10
|
+
].each do |friendly_string, method_signature|
|
|
11
|
+
assert_equal friendly_string, BitClust::MethodSignature.parse(method_signature).friendly_string
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
require 'test/unit'
|
|
2
|
+
require 'bitclust/nameutils'
|
|
3
|
+
|
|
4
|
+
class TestNameUtils < Test::Unit::TestCase
|
|
5
|
+
|
|
6
|
+
include BitClust::NameUtils
|
|
7
|
+
|
|
8
|
+
def test_libname?
|
|
9
|
+
assert_equal true, libname?("_builtin")
|
|
10
|
+
assert_equal true, libname?("fileutils")
|
|
11
|
+
assert_equal true, libname?("socket")
|
|
12
|
+
assert_equal true, libname?("open-uri")
|
|
13
|
+
assert_equal true, libname?("net/http")
|
|
14
|
+
assert_equal true, libname?("racc/cparse")
|
|
15
|
+
assert_equal true, libname?("test/unit/testcase")
|
|
16
|
+
assert_equal false, libname?("")
|
|
17
|
+
assert_equal false, libname?("fileutils ")
|
|
18
|
+
assert_equal false, libname?(" fileutils")
|
|
19
|
+
assert_equal false, libname?("file utils")
|
|
20
|
+
assert_equal false, libname?("fileutils\n")
|
|
21
|
+
assert_equal false, libname?("fileutils\t")
|
|
22
|
+
assert_equal false, libname?("fileutils.rb")
|
|
23
|
+
assert_equal false, libname?("English.rb")
|
|
24
|
+
assert_equal false, libname?("socket.so")
|
|
25
|
+
assert_equal false, libname?("net/http.rb")
|
|
26
|
+
assert_equal false, libname?("racc/cparse.so")
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def test_libname2id
|
|
30
|
+
assert_equal "_builtin", libname2id("_builtin")
|
|
31
|
+
assert_equal "fileutils", libname2id("fileutils")
|
|
32
|
+
assert_equal "socket", libname2id("socket")
|
|
33
|
+
assert_equal "English", libname2id("English")
|
|
34
|
+
assert_equal "open=2duri", libname2id("open-uri")
|
|
35
|
+
assert_equal "net.http", libname2id("net/http")
|
|
36
|
+
assert_equal "racc.cparse", libname2id("racc/cparse")
|
|
37
|
+
assert_equal "test.unit.testcase", libname2id("test/unit/testcase")
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def test_libid2name
|
|
41
|
+
assert_equal "_builtin", libid2name("_builtin")
|
|
42
|
+
assert_equal "fileutils", libid2name("fileutils")
|
|
43
|
+
assert_equal "socket", libid2name("socket")
|
|
44
|
+
assert_equal "English", libid2name("English")
|
|
45
|
+
assert_equal "open-uri", libid2name("open=2duri")
|
|
46
|
+
assert_equal "net/http", libid2name("net.http")
|
|
47
|
+
assert_equal "racc/cparse", libid2name("racc.cparse")
|
|
48
|
+
assert_equal "test/unit/testcase", libid2name("test.unit.testcase")
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def test_classname?
|
|
52
|
+
assert_equal true, classname?("fatal")
|
|
53
|
+
assert_equal true, classname?("Array")
|
|
54
|
+
assert_equal true, classname?("String")
|
|
55
|
+
assert_equal true, classname?("Net::HTTP")
|
|
56
|
+
assert_equal true, classname?("Test::Unit::TestCase")
|
|
57
|
+
assert_equal false, classname?("")
|
|
58
|
+
assert_equal false, classname?("Array ")
|
|
59
|
+
assert_equal false, classname?(" Array")
|
|
60
|
+
assert_equal false, classname?("Test Case")
|
|
61
|
+
assert_equal false, classname?("TestCase\n")
|
|
62
|
+
assert_equal false, classname?("\tTestCase")
|
|
63
|
+
assert_equal false, classname?("string")
|
|
64
|
+
assert_equal false, classname?("stringScanner")
|
|
65
|
+
assert_equal false, classname?("net/http")
|
|
66
|
+
assert_equal false, classname?("net.http")
|
|
67
|
+
assert_equal false, classname?("open-uri")
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def test_classname2id
|
|
71
|
+
assert_equal "Array", classname2id("Array")
|
|
72
|
+
assert_equal "String", classname2id("String")
|
|
73
|
+
assert_equal "Net=HTTP", classname2id("Net::HTTP")
|
|
74
|
+
assert_equal "Test=Unit=TestCase", classname2id("Test::Unit::TestCase")
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def test_classid2name
|
|
78
|
+
assert_equal "Array", classid2name("Array")
|
|
79
|
+
assert_equal "String", classid2name("String")
|
|
80
|
+
assert_equal "Net::HTTP", classid2name("Net=HTTP")
|
|
81
|
+
assert_equal "Test::Unit::TestCase", classid2name("Test=Unit=TestCase")
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def test_method_spec?
|
|
85
|
+
assert_equal true, method_spec?("String#index")
|
|
86
|
+
assert_equal true, method_spec?("CGI#accept")
|
|
87
|
+
assert_equal true, method_spec?("Net::HTTP#ca_path")
|
|
88
|
+
assert_equal true, method_spec?("FileUtils.#cp")
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def test_methodid2spec
|
|
92
|
+
assert_equal "String#index", methodid2specstring("String/i.index._builtin")
|
|
93
|
+
assert_equal "CGI#accept", methodid2specstring("CGI/i.accept.cgi")
|
|
94
|
+
assert_equal "Net::HTTP#ca_path", methodid2specstring("Net=HTTP/i.ca_path.net.http")
|
|
95
|
+
assert_equal "FileUtils.#cp", methodid2specstring("FileUtils/m.cp.fileutils")
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def test_methodid2libid
|
|
99
|
+
assert_equal "_builtin", methodid2libid("String/i.index._builtin")
|
|
100
|
+
assert_equal "cgi", methodid2libid("CGI/i.accept.cgi")
|
|
101
|
+
assert_equal "net.http", methodid2libid("Net=HTTP/i.ca_path.net.http")
|
|
102
|
+
assert_equal "open=2duri", methodid2libid("OpenURI/m.open.open=2duri")
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def test_methodid2classid
|
|
106
|
+
assert_equal "String", methodid2classid("String/i.index._builtin")
|
|
107
|
+
assert_equal "CGI", methodid2classid("CGI/i.accept.cgi")
|
|
108
|
+
assert_equal "Net=HTTP", methodid2classid("Net=HTTP/i.ca_path.net.http")
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def test_methodid2typename
|
|
112
|
+
assert_equal :instance_method, methodid2typename("String/i.index._builtin")
|
|
113
|
+
assert_equal :instance_method, methodid2typename("CGI/i.accept.cgi")
|
|
114
|
+
assert_equal :instance_method, methodid2typename("Net=HTTP/i.ca_path.net.http")
|
|
115
|
+
assert_equal :singleton_method, methodid2typename("String/s.new._builtin")
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def test_methodid2mname
|
|
119
|
+
assert_equal "index", methodid2mname("String/i.index._builtin")
|
|
120
|
+
assert_equal "accept", methodid2mname("CGI/i.accept.cgi")
|
|
121
|
+
assert_equal "ca_path", methodid2mname("Net=HTTP/i.ca_path.net.http")
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def test_methodname?
|
|
125
|
+
assert_equal true, methodname?("index")
|
|
126
|
+
assert_equal true, methodname?("accept")
|
|
127
|
+
assert_equal true, methodname?("get")
|
|
128
|
+
assert_equal true, methodname?("Array")
|
|
129
|
+
assert_equal true, methodname?("getIndex")
|
|
130
|
+
assert_equal true, methodname?("PROXY")
|
|
131
|
+
assert_equal true, methodname?("HTTP_PROXY")
|
|
132
|
+
assert_equal true, methodname?("gsub!")
|
|
133
|
+
assert_equal true, methodname?("empty?")
|
|
134
|
+
assert_equal true, methodname?("instance_eval")
|
|
135
|
+
assert_equal true, methodname?("__send")
|
|
136
|
+
assert_equal true, methodname?("__send__")
|
|
137
|
+
assert_equal true, methodname?("__send!")
|
|
138
|
+
assert_equal true, methodname?("+")
|
|
139
|
+
assert_equal true, methodname?("-")
|
|
140
|
+
assert_equal true, methodname?("*")
|
|
141
|
+
assert_equal true, methodname?("/")
|
|
142
|
+
assert_equal true, methodname?("&")
|
|
143
|
+
assert_equal true, methodname?("|")
|
|
144
|
+
assert_equal true, methodname?("^")
|
|
145
|
+
assert_equal true, methodname?("`")
|
|
146
|
+
assert_equal true, methodname?(">>")
|
|
147
|
+
assert_equal true, methodname?("<<")
|
|
148
|
+
assert_equal true, methodname?("+@")
|
|
149
|
+
assert_equal true, methodname?("-@")
|
|
150
|
+
assert_equal true, methodname?("!")
|
|
151
|
+
assert_equal true, methodname?("!@")
|
|
152
|
+
assert_equal true, methodname?("~")
|
|
153
|
+
assert_equal true, methodname?("**")
|
|
154
|
+
assert_equal true, methodname?("<")
|
|
155
|
+
assert_equal true, methodname?(">")
|
|
156
|
+
assert_equal true, methodname?("<=")
|
|
157
|
+
assert_equal true, methodname?(">=")
|
|
158
|
+
assert_equal true, methodname?("==")
|
|
159
|
+
assert_equal true, methodname?("===")
|
|
160
|
+
assert_equal true, methodname?("=~")
|
|
161
|
+
assert_equal true, methodname?("[]")
|
|
162
|
+
assert_equal true, methodname?("[]=")
|
|
163
|
+
|
|
164
|
+
assert_equal false, methodname?("")
|
|
165
|
+
assert_equal true, methodname?("!=")
|
|
166
|
+
assert_equal false, methodname?("!~")
|
|
167
|
+
assert_equal false, methodname?("&&")
|
|
168
|
+
assert_equal false, methodname?("||")
|
|
169
|
+
assert_equal false, methodname?("++")
|
|
170
|
+
assert_equal false, methodname?(">>>")
|
|
171
|
+
assert_equal false, methodname?("***")
|
|
172
|
+
assert_equal false, methodname?("====")
|
|
173
|
+
assert_equal false, methodname?("#accept")
|
|
174
|
+
assert_equal false, methodname?(".new")
|
|
175
|
+
assert_equal false, methodname?(".#cp")
|
|
176
|
+
assert_equal false, methodname?("$gvar")
|
|
177
|
+
assert_equal false, methodname?("CGI#accept")
|
|
178
|
+
assert_equal false, methodname?("String.new")
|
|
179
|
+
assert_equal false, methodname?("Net::HTTP.get")
|
|
180
|
+
assert_equal false, methodname?("Net::HTTP.new")
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
def test_build_method_id
|
|
184
|
+
assert_equal "String/i.index._builtin",
|
|
185
|
+
build_method_id("_builtin", "String", :instance_method, "index")
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
# library private
|
|
189
|
+
#def test_split_method_id
|
|
190
|
+
# assert_equal ["String", "i", "index", "_builtin"],
|
|
191
|
+
# split_method_id("String/i.index._builtin")
|
|
192
|
+
#end
|
|
193
|
+
|
|
194
|
+
def test_typename?
|
|
195
|
+
assert_equal true, typename?(:instance_method)
|
|
196
|
+
assert_equal true, typename?(:singleton_method)
|
|
197
|
+
assert_equal true, typename?(:module_function)
|
|
198
|
+
assert_equal true, typename?(:constant)
|
|
199
|
+
assert_equal true, typename?(:special_variable)
|
|
200
|
+
assert_equal false, typename?(:instance_eval)
|
|
201
|
+
assert_equal false, typename?(:instance)
|
|
202
|
+
assert_equal false, typename?(:singleton)
|
|
203
|
+
assert_equal false, typename?("i")
|
|
204
|
+
assert_equal false, typename?("s")
|
|
205
|
+
assert_equal false, typename?(:i)
|
|
206
|
+
assert_equal false, typename?(:s)
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
def test_typemark?
|
|
210
|
+
assert_equal true, typemark?('.')
|
|
211
|
+
assert_equal true, typemark?('#')
|
|
212
|
+
assert_equal true, typemark?('.#')
|
|
213
|
+
assert_equal true, typemark?('$')
|
|
214
|
+
assert_equal true, typemark?('::')
|
|
215
|
+
#marks = (0..255).map {|a| (0..255).map {|b| a.chr + b.chr } }.flatten
|
|
216
|
+
marks = (0..127).map {|a| (0..127).map {|b| a.chr + b.chr } }.flatten
|
|
217
|
+
(marks - %w( . # .# $ :: )).each do |m|
|
|
218
|
+
assert_equal false, typemark?(m)
|
|
219
|
+
end
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
def test_typechar?
|
|
223
|
+
typechars = %w( i s m c v )
|
|
224
|
+
typechars.each do |c|
|
|
225
|
+
assert_equal true, typechar?(c)
|
|
226
|
+
end
|
|
227
|
+
((0..255).map {|b| b.chr } - typechars).each do |c|
|
|
228
|
+
assert_equal false, typechar?(c)
|
|
229
|
+
end
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
def test_typename2char
|
|
233
|
+
assert_equal 's', typename2char(:singleton_method)
|
|
234
|
+
assert_equal 'i', typename2char(:instance_method)
|
|
235
|
+
assert_equal 'm', typename2char(:module_function)
|
|
236
|
+
assert_equal 'c', typename2char(:constant)
|
|
237
|
+
assert_equal 'v', typename2char(:special_variable)
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
def test_typechar2name
|
|
241
|
+
assert_equal :singleton_method, typechar2name('s')
|
|
242
|
+
assert_equal :instance_method, typechar2name('i')
|
|
243
|
+
assert_equal :module_function, typechar2name('m')
|
|
244
|
+
assert_equal :constant, typechar2name('c')
|
|
245
|
+
assert_equal :special_variable, typechar2name('v')
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
def test_typemark2char
|
|
249
|
+
assert_equal 's', typemark2char('.')
|
|
250
|
+
assert_equal 'i', typemark2char('#')
|
|
251
|
+
assert_equal 'm', typemark2char('.#')
|
|
252
|
+
assert_equal 'c', typemark2char('::')
|
|
253
|
+
assert_equal 'v', typemark2char('$')
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
def test_typechar2mark
|
|
257
|
+
assert_equal '.', typechar2mark('s')
|
|
258
|
+
assert_equal '#', typechar2mark('i')
|
|
259
|
+
assert_equal '.#', typechar2mark('m')
|
|
260
|
+
assert_equal '::', typechar2mark('c')
|
|
261
|
+
assert_equal '$', typechar2mark('v')
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
def test_encodename_url
|
|
265
|
+
assert_equal "Array", encodename_url("Array")
|
|
266
|
+
assert_equal "String", encodename_url("String")
|
|
267
|
+
assert_equal "index", encodename_url("index")
|
|
268
|
+
assert_equal "=2a", encodename_url("*")
|
|
269
|
+
assert_equal "=2a=2a", encodename_url("**")
|
|
270
|
+
assert_equal "open=2duri", encodename_url("open-uri")
|
|
271
|
+
assert_equal "net=2ehttp", encodename_url("net.http")
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
def test_decodename_url
|
|
275
|
+
assert_equal "Array", decodename_url("Array")
|
|
276
|
+
assert_equal "String", decodename_url("String")
|
|
277
|
+
assert_equal "index", decodename_url("index")
|
|
278
|
+
assert_equal "*", decodename_url("=2a")
|
|
279
|
+
assert_equal "**", decodename_url("=2a=2a")
|
|
280
|
+
assert_equal "open-uri", decodename_url("open=2duri")
|
|
281
|
+
assert_equal "net.http", decodename_url("net=2ehttp")
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
def test_encodeid
|
|
285
|
+
assert_equal "-array", encodeid("Array")
|
|
286
|
+
assert_equal "-string", encodeid("String")
|
|
287
|
+
assert_equal "-c-g-i", encodeid("CGI")
|
|
288
|
+
assert_equal "=2a", encodeid("=2a")
|
|
289
|
+
assert_equal "=2a=2a", encodeid("=2a=2a")
|
|
290
|
+
assert_equal "open=2duri", encodeid("open=2duri")
|
|
291
|
+
assert_equal "-net=-h-t-t-p", encodeid("Net=HTTP")
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
def test_decodeid
|
|
295
|
+
assert_equal "Array", decodeid("-array")
|
|
296
|
+
assert_equal "String", decodeid("-string")
|
|
297
|
+
assert_equal "CGI", decodeid("-c-g-i")
|
|
298
|
+
assert_equal "=2a", decodeid("=2a")
|
|
299
|
+
assert_equal "=2a=2a", decodeid("=2a=2a")
|
|
300
|
+
assert_equal "open=2duri", decodeid("open=2duri")
|
|
301
|
+
assert_equal "Net=HTTP", decodeid("-net=-h-t-t-p")
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
def test_encodename_fs
|
|
305
|
+
assert_equal "-array", encodename_fs("Array")
|
|
306
|
+
assert_equal "-string", encodename_fs("String")
|
|
307
|
+
assert_equal "index", encodename_fs("index")
|
|
308
|
+
assert_equal "=2a", encodename_fs("*")
|
|
309
|
+
assert_equal "=2a=2a", encodename_fs("**")
|
|
310
|
+
assert_equal "open=2duri", encodename_fs("open-uri")
|
|
311
|
+
assert_equal "net=2ehttp", encodename_fs("net.http")
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
def test_decodename_fs
|
|
315
|
+
assert_equal "Array", decodename_fs("-array")
|
|
316
|
+
assert_equal "String", decodename_fs("-string")
|
|
317
|
+
assert_equal "index", decodename_fs("index")
|
|
318
|
+
assert_equal "*", decodename_fs("=2a")
|
|
319
|
+
assert_equal "**", decodename_fs("=2a=2a")
|
|
320
|
+
assert_equal "open-uri", decodename_fs("open=2duri")
|
|
321
|
+
assert_equal "net.http", decodename_fs("net=2ehttp")
|
|
322
|
+
end
|
|
323
|
+
|
|
324
|
+
end
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
require 'test/unit'
|
|
2
|
+
require 'bitclust/preprocessor'
|
|
3
|
+
require 'stringio'
|
|
4
|
+
|
|
5
|
+
class TestPreprocessor < Test::Unit::TestCase
|
|
6
|
+
include BitClust
|
|
7
|
+
def test_eval_cond
|
|
8
|
+
params = { 'version' => '1.8.7' }
|
|
9
|
+
|
|
10
|
+
[
|
|
11
|
+
['#@if( version > "1.8.0")', true ],
|
|
12
|
+
['#@if( version < "1.8.0")', false],
|
|
13
|
+
['#@if( version <= "1.8.7")', true ],
|
|
14
|
+
['#@if( version >= "1.9.1")', false],
|
|
15
|
+
['#@if( version == "1.8.7")', true ],
|
|
16
|
+
['#@if( version != "1.9.0")', true ],
|
|
17
|
+
['#@if( "1.9.0" != version)', true ],
|
|
18
|
+
|
|
19
|
+
['#@since 1.8.0', true ],
|
|
20
|
+
['#@since 1.8.7', true ],
|
|
21
|
+
['#@until 1.8.7', false],
|
|
22
|
+
['#@until 1.9.0', true ],
|
|
23
|
+
|
|
24
|
+
['#@if( version > "1.8.0" and version < "1.9.0")', true ],
|
|
25
|
+
['#@if( version > "1.8.9" and version < "1.9.0")', false],
|
|
26
|
+
['#@if( version > "1.8.9" or version < "1.9.0")', true ],
|
|
27
|
+
['#@if( version < "1.8.0" or version > "1.9.0")', false],
|
|
28
|
+
['#@if( version > "1.8.0" and version < "1.9.0" and version < "1.9.1")', true ],
|
|
29
|
+
['#@if( version > "1.8.0" and version < "1.9.0" and version > "1.9.1")', false],
|
|
30
|
+
['#@if( version < "1.8.0" and version > "1.9.0" or "1.9.1" != version)', true ],
|
|
31
|
+
].each{|cond, expected_result|
|
|
32
|
+
s = <<HERE
|
|
33
|
+
#{cond}
|
|
34
|
+
a
|
|
35
|
+
\#@else
|
|
36
|
+
b
|
|
37
|
+
\#@end
|
|
38
|
+
HERE
|
|
39
|
+
ret = Preprocessor.wrap(StringIO.new(s), params).to_a
|
|
40
|
+
if expected_result
|
|
41
|
+
assert_equal(["a\n"], ret)
|
|
42
|
+
else
|
|
43
|
+
assert_equal(["b\n"], ret)
|
|
44
|
+
end
|
|
45
|
+
}
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def test_todo
|
|
49
|
+
params = { 'version' => '1.8.7' }
|
|
50
|
+
src = <<HERE
|
|
51
|
+
--- puts(str) -> String
|
|
52
|
+
\#@todo
|
|
53
|
+
description
|
|
54
|
+
HERE
|
|
55
|
+
expected = <<HERE
|
|
56
|
+
--- puts(str) -> String
|
|
57
|
+
@todo
|
|
58
|
+
description
|
|
59
|
+
HERE
|
|
60
|
+
ret = Preprocessor.wrap(StringIO.new(src), params).to_a
|
|
61
|
+
assert_equal(expected, ret.join)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def test_todo_with_condition
|
|
65
|
+
params = { 'version' => '1.9.2' }
|
|
66
|
+
src = <<HERE
|
|
67
|
+
--- puts(str) -> String
|
|
68
|
+
\#@since 1.9.2
|
|
69
|
+
\#@todo 1.9.2
|
|
70
|
+
\#@else
|
|
71
|
+
\#@todo old
|
|
72
|
+
\#@end
|
|
73
|
+
description
|
|
74
|
+
HERE
|
|
75
|
+
expected = <<HERE
|
|
76
|
+
--- puts(str) -> String
|
|
77
|
+
@todo 1.9.2
|
|
78
|
+
description
|
|
79
|
+
HERE
|
|
80
|
+
ret = Preprocessor.wrap(StringIO.new(src), params).to_a
|
|
81
|
+
assert_equal(expected, ret.join)
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
@@ -0,0 +1,534 @@
|
|
|
1
|
+
require 'bitclust/rdcompiler'
|
|
2
|
+
require 'bitclust/database'
|
|
3
|
+
require 'bitclust/methoddatabase'
|
|
4
|
+
require 'bitclust/screen'
|
|
5
|
+
require 'test/unit'
|
|
6
|
+
require 'timeout'
|
|
7
|
+
|
|
8
|
+
class TestRDCompiler < Test::Unit::TestCase
|
|
9
|
+
|
|
10
|
+
def setup
|
|
11
|
+
@dummy = 'dummy'
|
|
12
|
+
@u = BitClust::URLMapper.new(Hash.new{@dummy})
|
|
13
|
+
@c = BitClust::RDCompiler.new(@u, 1, {:database => BitClust::MethodDatabase.dummy})
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def compile_and_assert_equal(expected, src)
|
|
17
|
+
assert_equal expected, @c.compile(src)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def test_dlist
|
|
21
|
+
src = <<'HERE'
|
|
22
|
+
: t1
|
|
23
|
+
c1
|
|
24
|
+
: t2
|
|
25
|
+
c2-1
|
|
26
|
+
c2-2
|
|
27
|
+
HERE
|
|
28
|
+
expected = <<'HERE'
|
|
29
|
+
<dl>
|
|
30
|
+
<dt>t1</dt>
|
|
31
|
+
<dd>
|
|
32
|
+
<p>
|
|
33
|
+
c1
|
|
34
|
+
</p>
|
|
35
|
+
</dd>
|
|
36
|
+
<dt>t2</dt>
|
|
37
|
+
<dd>
|
|
38
|
+
<p>
|
|
39
|
+
c2-1
|
|
40
|
+
c2-2
|
|
41
|
+
</p>
|
|
42
|
+
</dd>
|
|
43
|
+
</dl>
|
|
44
|
+
HERE
|
|
45
|
+
compile_and_assert_equal(expected, src)
|
|
46
|
+
|
|
47
|
+
src = <<HERE
|
|
48
|
+
: t1
|
|
49
|
+
c1
|
|
50
|
+
|
|
51
|
+
: t2
|
|
52
|
+
c2
|
|
53
|
+
|
|
54
|
+
c3
|
|
55
|
+
HERE
|
|
56
|
+
expected = <<HERE
|
|
57
|
+
<dl>
|
|
58
|
+
<dt>t1</dt>
|
|
59
|
+
<dd>
|
|
60
|
+
<p>
|
|
61
|
+
c1
|
|
62
|
+
</p>
|
|
63
|
+
</dd>
|
|
64
|
+
<dt>t2</dt>
|
|
65
|
+
<dd>
|
|
66
|
+
<p>
|
|
67
|
+
c2
|
|
68
|
+
</p>
|
|
69
|
+
<p>
|
|
70
|
+
c3
|
|
71
|
+
</p>
|
|
72
|
+
</dd>
|
|
73
|
+
</dl>
|
|
74
|
+
HERE
|
|
75
|
+
compile_and_assert_equal(expected, src)
|
|
76
|
+
|
|
77
|
+
src = <<HERE
|
|
78
|
+
: t1
|
|
79
|
+
c1
|
|
80
|
+
//emlist{
|
|
81
|
+
hoge
|
|
82
|
+
//}
|
|
83
|
+
: t2
|
|
84
|
+
c2
|
|
85
|
+
HERE
|
|
86
|
+
expected = <<'HERE'
|
|
87
|
+
<dl>
|
|
88
|
+
<dt>t1</dt>
|
|
89
|
+
<dd>
|
|
90
|
+
<p>
|
|
91
|
+
c1
|
|
92
|
+
</p>
|
|
93
|
+
<pre>
|
|
94
|
+
hoge
|
|
95
|
+
</pre>
|
|
96
|
+
</dd>
|
|
97
|
+
<dt>t2</dt>
|
|
98
|
+
<dd>
|
|
99
|
+
<p>
|
|
100
|
+
c2
|
|
101
|
+
</p>
|
|
102
|
+
</dd>
|
|
103
|
+
</dl>
|
|
104
|
+
HERE
|
|
105
|
+
compile_and_assert_equal(expected, src)
|
|
106
|
+
|
|
107
|
+
src = <<HERE
|
|
108
|
+
: t1
|
|
109
|
+
c1
|
|
110
|
+
|
|
111
|
+
c2
|
|
112
|
+
|
|
113
|
+
text
|
|
114
|
+
HERE
|
|
115
|
+
expected = <<'HERE'
|
|
116
|
+
<dl>
|
|
117
|
+
<dt>t1</dt>
|
|
118
|
+
<dd>
|
|
119
|
+
<p>
|
|
120
|
+
c1
|
|
121
|
+
</p>
|
|
122
|
+
<p>
|
|
123
|
+
c2
|
|
124
|
+
</p>
|
|
125
|
+
</dd>
|
|
126
|
+
</dl>
|
|
127
|
+
<p>
|
|
128
|
+
text
|
|
129
|
+
</p>
|
|
130
|
+
HERE
|
|
131
|
+
compile_and_assert_equal(expected, src)
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def test_pre
|
|
135
|
+
src = <<'HERE'
|
|
136
|
+
<
|
|
137
|
+
hoge
|
|
138
|
+
|
|
139
|
+
foo
|
|
140
|
+
HERE
|
|
141
|
+
expected = <<'HERE'
|
|
142
|
+
<pre>
|
|
143
|
+
<
|
|
144
|
+
hoge
|
|
145
|
+
|
|
146
|
+
foo
|
|
147
|
+
</pre>
|
|
148
|
+
HERE
|
|
149
|
+
compile_and_assert_equal(expected, src)
|
|
150
|
+
|
|
151
|
+
src = <<'HERE'
|
|
152
|
+
pretext
|
|
153
|
+
|
|
154
|
+
* hoge1
|
|
155
|
+
HERE
|
|
156
|
+
expected = <<'HERE'
|
|
157
|
+
<pre>
|
|
158
|
+
pretext
|
|
159
|
+
|
|
160
|
+
* hoge1
|
|
161
|
+
</pre>
|
|
162
|
+
HERE
|
|
163
|
+
compile_and_assert_equal(expected, src)
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def test_method
|
|
167
|
+
src = <<'HERE'
|
|
168
|
+
--- hoge
|
|
169
|
+
foo
|
|
170
|
+
bar
|
|
171
|
+
text
|
|
172
|
+
HERE
|
|
173
|
+
expected = <<'HERE'
|
|
174
|
+
<dt class="method-heading"><code>hoge</code></dt>
|
|
175
|
+
<dd class="method-description">
|
|
176
|
+
<p>
|
|
177
|
+
foo
|
|
178
|
+
bar
|
|
179
|
+
</p>
|
|
180
|
+
<pre>
|
|
181
|
+
text
|
|
182
|
+
</pre>
|
|
183
|
+
</dd>
|
|
184
|
+
HERE
|
|
185
|
+
compile_and_assert_equal(expected, src)
|
|
186
|
+
|
|
187
|
+
src = <<'HERE'
|
|
188
|
+
--- <=>
|
|
189
|
+
|
|
190
|
+
abs
|
|
191
|
+
//emlist{
|
|
192
|
+
text
|
|
193
|
+
//}
|
|
194
|
+
HERE
|
|
195
|
+
expected = <<'HERE'
|
|
196
|
+
<dt class="method-heading"><code>self <=> </code></dt>
|
|
197
|
+
<dd class="method-description">
|
|
198
|
+
<p>
|
|
199
|
+
abs
|
|
200
|
+
</p>
|
|
201
|
+
<pre>
|
|
202
|
+
text
|
|
203
|
+
</pre>
|
|
204
|
+
</dd>
|
|
205
|
+
HERE
|
|
206
|
+
compile_and_assert_equal(expected, src)
|
|
207
|
+
|
|
208
|
+
src = <<'HERE'
|
|
209
|
+
--- method
|
|
210
|
+
|
|
211
|
+
: word1
|
|
212
|
+
dsc
|
|
213
|
+
HERE
|
|
214
|
+
expected = <<'HERE'
|
|
215
|
+
<dt class="method-heading"><code>method</code></dt>
|
|
216
|
+
<dd class="method-description">
|
|
217
|
+
<dl>
|
|
218
|
+
<dt>word1</dt>
|
|
219
|
+
<dd>
|
|
220
|
+
<p>
|
|
221
|
+
dsc
|
|
222
|
+
</p>
|
|
223
|
+
</dd>
|
|
224
|
+
</dl>
|
|
225
|
+
</dd>
|
|
226
|
+
HERE
|
|
227
|
+
compile_and_assert_equal(expected, src)
|
|
228
|
+
|
|
229
|
+
src = <<'HERE'
|
|
230
|
+
--- method
|
|
231
|
+
dsc
|
|
232
|
+
|
|
233
|
+
@param hoge dsc
|
|
234
|
+
@return dsc
|
|
235
|
+
|
|
236
|
+
@raise hoge dsc
|
|
237
|
+
@see hoge
|
|
238
|
+
HERE
|
|
239
|
+
expected = <<'HERE'
|
|
240
|
+
<dt class="method-heading"><code>method</code></dt>
|
|
241
|
+
<dd class="method-description">
|
|
242
|
+
<p>
|
|
243
|
+
dsc
|
|
244
|
+
</p>
|
|
245
|
+
<dl>
|
|
246
|
+
<dt class='method-param'>[PARAM] hoge:</dt>
|
|
247
|
+
<dd>
|
|
248
|
+
dsc
|
|
249
|
+
</dd>
|
|
250
|
+
<dt>[RETURN]</dt>
|
|
251
|
+
<dd>
|
|
252
|
+
dsc
|
|
253
|
+
</dd>
|
|
254
|
+
<dt>[EXCEPTION] hoge:</dt>
|
|
255
|
+
<dd>
|
|
256
|
+
dsc
|
|
257
|
+
</dd>
|
|
258
|
+
</dl>
|
|
259
|
+
<p>
|
|
260
|
+
[SEE_ALSO] hoge
|
|
261
|
+
</p>
|
|
262
|
+
</dd>
|
|
263
|
+
HERE
|
|
264
|
+
compile_and_assert_equal(expected, src)
|
|
265
|
+
|
|
266
|
+
src = <<'HERE'
|
|
267
|
+
--- method
|
|
268
|
+
|
|
269
|
+
@param arg dsc1
|
|
270
|
+
|
|
271
|
+
dsc2
|
|
272
|
+
dsc3
|
|
273
|
+
HERE
|
|
274
|
+
expected = <<'HERE'
|
|
275
|
+
<dt class="method-heading"><code>method</code></dt>
|
|
276
|
+
<dd class="method-description">
|
|
277
|
+
<dl>
|
|
278
|
+
<dt class='method-param'>[PARAM] arg:</dt>
|
|
279
|
+
<dd>
|
|
280
|
+
dsc1
|
|
281
|
+
</dd>
|
|
282
|
+
</dl>
|
|
283
|
+
<pre>
|
|
284
|
+
dsc2
|
|
285
|
+
dsc3
|
|
286
|
+
</pre>
|
|
287
|
+
</dd>
|
|
288
|
+
HERE
|
|
289
|
+
compile_and_assert_equal(expected, src)
|
|
290
|
+
|
|
291
|
+
src = <<'HERE'
|
|
292
|
+
--- method
|
|
293
|
+
|
|
294
|
+
@param arg dsc1
|
|
295
|
+
//emlist{
|
|
296
|
+
dsc2
|
|
297
|
+
dsc3
|
|
298
|
+
//}
|
|
299
|
+
HERE
|
|
300
|
+
expected = <<'HERE'
|
|
301
|
+
<dt class="method-heading"><code>method</code></dt>
|
|
302
|
+
<dd class="method-description">
|
|
303
|
+
<dl>
|
|
304
|
+
<dt class='method-param'>[PARAM] arg:</dt>
|
|
305
|
+
<dd>
|
|
306
|
+
dsc1
|
|
307
|
+
<pre>
|
|
308
|
+
dsc2
|
|
309
|
+
dsc3
|
|
310
|
+
</pre>
|
|
311
|
+
</dd>
|
|
312
|
+
</dl>
|
|
313
|
+
</dd>
|
|
314
|
+
HERE
|
|
315
|
+
compile_and_assert_equal(expected, src)
|
|
316
|
+
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
def test_method2
|
|
320
|
+
@c = BitClust::RDCompiler.new(@u, 1, {:force => true})
|
|
321
|
+
src = <<'HERE'
|
|
322
|
+
--- hoge1
|
|
323
|
+
--- hoge2
|
|
324
|
+
bar
|
|
325
|
+
HERE
|
|
326
|
+
expected = <<'HERE'
|
|
327
|
+
<dl>
|
|
328
|
+
<dt class="method-heading"><code>hoge1</code></dt>
|
|
329
|
+
<dt class="method-heading"><code>hoge2</code></dt>
|
|
330
|
+
<dd class="method-description">
|
|
331
|
+
<p>
|
|
332
|
+
bar
|
|
333
|
+
</p>
|
|
334
|
+
</dd>
|
|
335
|
+
</dl>
|
|
336
|
+
HERE
|
|
337
|
+
compile_and_assert_equal(expected, src)
|
|
338
|
+
end
|
|
339
|
+
|
|
340
|
+
def test_ulist
|
|
341
|
+
src = <<'HERE'
|
|
342
|
+
* hoge1
|
|
343
|
+
* hoge2
|
|
344
|
+
HERE
|
|
345
|
+
expected = <<'HERE'
|
|
346
|
+
<ul>
|
|
347
|
+
<li>hoge1</li>
|
|
348
|
+
<li>hoge2</li>
|
|
349
|
+
</ul>
|
|
350
|
+
HERE
|
|
351
|
+
compile_and_assert_equal(expected, src)
|
|
352
|
+
|
|
353
|
+
src = <<'HERE'
|
|
354
|
+
* hoge1
|
|
355
|
+
|
|
356
|
+
* hoge2
|
|
357
|
+
HERE
|
|
358
|
+
expected = <<'HERE'
|
|
359
|
+
<ul>
|
|
360
|
+
<li>hoge1</li>
|
|
361
|
+
</ul>
|
|
362
|
+
<ul>
|
|
363
|
+
<li>hoge2</li>
|
|
364
|
+
</ul>
|
|
365
|
+
HERE
|
|
366
|
+
compile_and_assert_equal(expected, src)
|
|
367
|
+
|
|
368
|
+
src = <<'HERE'
|
|
369
|
+
* hoge1
|
|
370
|
+
bar
|
|
371
|
+
* hoge2
|
|
372
|
+
HERE
|
|
373
|
+
expected = <<'HERE'
|
|
374
|
+
<ul>
|
|
375
|
+
<li>hoge1
|
|
376
|
+
bar</li>
|
|
377
|
+
<li>hoge2</li>
|
|
378
|
+
</ul>
|
|
379
|
+
HERE
|
|
380
|
+
compile_and_assert_equal(expected, src)
|
|
381
|
+
|
|
382
|
+
end
|
|
383
|
+
|
|
384
|
+
def test_olist
|
|
385
|
+
src = <<'HERE'
|
|
386
|
+
(1) hoge1
|
|
387
|
+
bar
|
|
388
|
+
(2) hoge2
|
|
389
|
+
HERE
|
|
390
|
+
expected = <<'HERE'
|
|
391
|
+
<ol>
|
|
392
|
+
<li>hoge1
|
|
393
|
+
bar</li>
|
|
394
|
+
<li>hoge2</li>
|
|
395
|
+
</ol>
|
|
396
|
+
HERE
|
|
397
|
+
compile_and_assert_equal(expected, src)
|
|
398
|
+
end
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
def test_invalid_case
|
|
402
|
+
src = <<HERE
|
|
403
|
+
: t1
|
|
404
|
+
c1
|
|
405
|
+
//e
|
|
406
|
+
hoge
|
|
407
|
+
//}
|
|
408
|
+
HERE
|
|
409
|
+
Timeout.timeout(10) do
|
|
410
|
+
assert @c.compile(src)
|
|
411
|
+
end
|
|
412
|
+
end
|
|
413
|
+
|
|
414
|
+
def test_bracket_link
|
|
415
|
+
[
|
|
416
|
+
['[[c:String]]', '<a href="dummy/class/String">String</a>' ],
|
|
417
|
+
['[[c:String ]]', '[[c:String ]]' ],
|
|
418
|
+
['[[String]]', '[[String]]' ],
|
|
419
|
+
['[[c:File::Stat]]', '<a href="dummy/class/File=Stat">File::Stat</a>' ],
|
|
420
|
+
['[[m:String.new]]', '<a href="dummy/method/String/s/new">String.new</a>'],
|
|
421
|
+
['[[m:String#dump]]', '<a href="dummy/method/String/i/dump">String#dump</a>'],
|
|
422
|
+
['[[m:String#[] ]]', '<a href="dummy/method/String/i/=5b=5d">String#[]</a>'],
|
|
423
|
+
['[[f:rb_ary_new3]]', '<a href="dummy/function/rb_ary_new3">rb_ary_new3</a>'],
|
|
424
|
+
['[[f:/]]', '<a href="dummy/function/">All C API</a>'],
|
|
425
|
+
['[[f:_index]]', '<a href="dummy/function/">All C API</a>'],
|
|
426
|
+
['[[lib:jcode]]', '<a href="dummy/library/jcode">jcode</a>'],
|
|
427
|
+
['[[man:tr(1)]]', '<a class="external" href="http://www.opengroup.org/onlinepubs/009695399/utilities/tr.html">tr(1)</a>'],
|
|
428
|
+
['[[man:sys/socket.h(header)]]', '<a class="external" href="http://www.opengroup.org/onlinepubs/009695399/basedefs/sys/socket.h.html">sys/socket.h(header)</a>'],
|
|
429
|
+
['[[man:fopen(3linux)]]', '<a class="external" href="http://man7.org/linux/man-pages/man3/fopen.3.html">fopen(3linux)</a>'],
|
|
430
|
+
['[[RFC:2822]]', '<a class="external" href="http://www.ietf.org/rfc/rfc2822.txt">[RFC2822]</a>'],
|
|
431
|
+
['[[m:$~]]', '<a href="dummy/method/Kernel/v/=7e">$~</a>'],
|
|
432
|
+
['[[m:$,]]', '<a href="dummy/method/Kernel/v/=2c">$,</a>'],
|
|
433
|
+
['[[c:String]]]', '<a href="dummy/class/String">String</a>]'],
|
|
434
|
+
['[[c:String]][[c:String]]',
|
|
435
|
+
'<a href="dummy/class/String">String</a><a href="dummy/class/String">String</a>'],
|
|
436
|
+
['[[m:File::SEPARATOR]]', '<a href="dummy/method/File/c/SEPARATOR">File::SEPARATOR</a>'],
|
|
437
|
+
['[[url:http://i.loveruby.net]]', '<a class="external" href="http://i.loveruby.net">http://i.loveruby.net</a>'],
|
|
438
|
+
['[[ruby-list:12345]]',
|
|
439
|
+
'<a class="external" href="http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-list/12345">[ruby-list:12345]</a>'],
|
|
440
|
+
].each{|src, expected|
|
|
441
|
+
assert_equal expected, @c.send(:compile_text, src), src
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
[
|
|
445
|
+
['[[d:hoge/bar]]', '<a href="dummy/hoge/bar">.*</a>'],
|
|
446
|
+
['[[ref:d:hoge/bar#frag]]', '<a href="dummy/hoge/bar#frag">.*</a>'],
|
|
447
|
+
['[[ref:c:Hoge#frag]]', '<a href="dummy/class/Hoge#frag">.*</a>'],
|
|
448
|
+
['[[ref:m:$~#frag]]', '<a href="dummy/method/Kernel/v/=7e#frag">.*</a>'],
|
|
449
|
+
['[[ref:lib:jcode#frag]]', '<a href="dummy/library/jcode#frag">.*</a>'],
|
|
450
|
+
|
|
451
|
+
['[[ref:c:Hoge]]', 'compileerror'],
|
|
452
|
+
['[[ref:ref:hoge/bar#frag]]', 'compileerror'],
|
|
453
|
+
].each{|src, expected|
|
|
454
|
+
assert_match /#{expected}/, @c.send(:compile_text, src), src
|
|
455
|
+
}
|
|
456
|
+
end
|
|
457
|
+
|
|
458
|
+
def test_array_join
|
|
459
|
+
src = <<'HERE'
|
|
460
|
+
--- join(sep = $,) -> String
|
|
461
|
+
|
|
462
|
+
@see [[m:Array#*]], [[m:$,]]
|
|
463
|
+
HERE
|
|
464
|
+
expected = <<'HERE'
|
|
465
|
+
<dt class="method-heading"><code>join(sep = $,) -> String</code></dt>
|
|
466
|
+
<dd class="method-description">
|
|
467
|
+
<p>
|
|
468
|
+
[SEE_ALSO] <a href="dummy/method/Array/i/=2a">Array#*</a>, <a href="dummy/method/Kernel/v/=2c">$,</a>
|
|
469
|
+
</p>
|
|
470
|
+
</dd>
|
|
471
|
+
HERE
|
|
472
|
+
compile_and_assert_equal(expected, src)
|
|
473
|
+
end
|
|
474
|
+
|
|
475
|
+
def test_todo
|
|
476
|
+
src = <<'HERE'
|
|
477
|
+
--- puts(str) -> String
|
|
478
|
+
@todo
|
|
479
|
+
|
|
480
|
+
description
|
|
481
|
+
HERE
|
|
482
|
+
expected = <<'HERE'
|
|
483
|
+
<dt class="method-heading"><code>puts(str) -> String</code></dt>
|
|
484
|
+
<dd class="method-description">
|
|
485
|
+
<p class="todo">
|
|
486
|
+
[TODO]
|
|
487
|
+
</p>
|
|
488
|
+
<p>
|
|
489
|
+
description
|
|
490
|
+
</p>
|
|
491
|
+
</dd>
|
|
492
|
+
HERE
|
|
493
|
+
compile_and_assert_equal(expected, src)
|
|
494
|
+
end
|
|
495
|
+
|
|
496
|
+
def test_todo_with_comment
|
|
497
|
+
src = <<'HERE'
|
|
498
|
+
--- puts(str) -> String
|
|
499
|
+
@todo 1.9.2
|
|
500
|
+
|
|
501
|
+
description
|
|
502
|
+
HERE
|
|
503
|
+
expected = <<'HERE'
|
|
504
|
+
<dt class="method-heading"><code>puts(str) -> String</code></dt>
|
|
505
|
+
<dd class="method-description">
|
|
506
|
+
<p class="todo">
|
|
507
|
+
[TODO] 1.9.2
|
|
508
|
+
</p>
|
|
509
|
+
<p>
|
|
510
|
+
description
|
|
511
|
+
</p>
|
|
512
|
+
</dd>
|
|
513
|
+
HERE
|
|
514
|
+
compile_and_assert_equal(expected, src)
|
|
515
|
+
end
|
|
516
|
+
|
|
517
|
+
|
|
518
|
+
class BitClust::RDCompiler; public :man_url; end
|
|
519
|
+
|
|
520
|
+
def test_man_url
|
|
521
|
+
assert_equal("http://www.opengroup.org/onlinepubs/009695399/utilities/tr.html",
|
|
522
|
+
@c.man_url("1", "tr"))
|
|
523
|
+
assert_equal("http://www.opengroup.org/onlinepubs/009695399/functions/fopen.html",
|
|
524
|
+
@c.man_url("3", "fopen"))
|
|
525
|
+
assert_equal("http://www.opengroup.org/onlinepubs/009695399/basedefs/sys/socket.h.html",
|
|
526
|
+
@c.man_url("header", "sys/socket.h"))
|
|
527
|
+
assert_equal("http://man7.org/linux/man-pages/man3/fopen.3.html",
|
|
528
|
+
@c.man_url("3linux", "fopen"))
|
|
529
|
+
assert_equal("http://www.freebsd.org/cgi/man.cgi?query=fopen&sektion=3&manpath=FreeBSD+9.0-RELEASE",
|
|
530
|
+
@c.man_url("3freebsd", "fopen"))
|
|
531
|
+
assert_equal(nil, @c.man_url("foo", "tr"))
|
|
532
|
+
|
|
533
|
+
end
|
|
534
|
+
end
|