3
3
4
4
require_relative 'helper'
5
5
6
- class TestRDocComment < RDoc ::TestCase
6
+ class RDocCommentTest < RDoc ::TestCase
7
7
8
8
def setup
9
9
super
@@ -42,74 +42,54 @@ def test_equals2
42
42
end
43
43
44
44
def test_extract_call_seq
45
- m = RDoc ::AnyMethod . new nil , 'm'
46
-
47
45
comment = RDoc ::Comment . new <<-COMMENT , @top_level
48
46
call-seq:
49
47
bla => true or false
50
48
51
49
moar comment
52
50
COMMENT
53
51
54
- comment . extract_call_seq m
55
-
56
- assert_equal "bla => true or false\n " , m . call_seq
52
+ assert_equal "bla => true or false\n " , comment . extract_call_seq
57
53
end
58
54
59
55
def test_extract_call_seq_blank
60
- m = RDoc ::AnyMethod . new nil , 'm'
61
-
62
56
comment = RDoc ::Comment . new <<-COMMENT , @top_level
63
57
call-seq:
64
58
bla => true or false
65
59
66
60
COMMENT
67
61
68
- comment . extract_call_seq m
69
-
70
- assert_equal "bla => true or false\n " , m . call_seq
62
+ assert_equal "bla => true or false\n " , comment . extract_call_seq
71
63
end
72
64
73
65
def test_extract_call_seq_commented
74
- m = RDoc ::AnyMethod . new nil , 'm'
75
-
76
66
comment = RDoc ::Comment . new <<-COMMENT , @top_level
77
67
# call-seq:
78
68
# bla => true or false
79
69
#
80
70
# moar comment
81
71
COMMENT
82
72
83
- comment . extract_call_seq m
84
-
85
- assert_nil m . call_seq
73
+ assert_nil comment . extract_call_seq
86
74
end
87
75
88
76
def test_extract_call_seq_no_blank
89
- m = RDoc ::AnyMethod . new nil , 'm'
90
-
91
77
comment = RDoc ::Comment . new <<-COMMENT , @top_level
92
78
call-seq:
93
79
bla => true or false
94
80
COMMENT
95
81
96
- comment . extract_call_seq m
97
-
98
- assert_equal "bla => true or false\n " , m . call_seq
82
+ assert_equal "bla => true or false\n " , comment . extract_call_seq
99
83
end
100
84
101
85
def test_extract_call_seq_undent
102
- m = RDoc ::AnyMethod . new nil , 'm'
103
-
104
86
comment = RDoc ::Comment . new <<-COMMENT , @top_level
105
87
call-seq:
106
88
bla => true or false
107
89
moar comment
108
90
COMMENT
109
91
110
- comment . extract_call_seq m
111
-
112
- assert_equal "bla => true or false\n moar comment\n " , m . call_seq
92
+ assert_equal "bla => true or false\n moar comment\n " , comment . extract_call_seq
113
93
end
114
94
115
95
def test_extract_call_seq_c
@@ -128,18 +108,14 @@ def test_extract_call_seq_c
128
108
and commercial week day given. Ignores the 4th argument.
129
109
COMMENT
130
110
131
- method_obj = RDoc ::AnyMethod . new nil , 'blah'
132
-
133
- comment . extract_call_seq method_obj
134
-
135
111
expected = <<-CALL_SEQ . chomp
136
112
commercial() -> Date <br />
137
113
commercial(cwyear, cweek=41, cwday=5, sg=nil) -> Date [ruby 1.8] <br />
138
114
commercial(cwyear, cweek=1, cwday=1, sg=nil) -> Date [ruby 1.9]
139
115
140
116
CALL_SEQ
141
117
142
- assert_equal expected , method_obj . call_seq
118
+ assert_equal expected , comment . extract_call_seq
143
119
end
144
120
145
121
def test_extract_call_seq_c_no_blank
@@ -150,18 +126,14 @@ def test_extract_call_seq_c_no_blank
150
126
commercial(cwyear, cweek=1, cwday=1, sg=nil) -> Date [ruby 1.9]
151
127
COMMENT
152
128
153
- method_obj = RDoc ::AnyMethod . new nil , 'blah'
154
-
155
- comment . extract_call_seq method_obj
156
-
157
129
expected = <<-CALL_SEQ . chomp
158
130
commercial() -> Date <br />
159
131
commercial(cwyear, cweek=41, cwday=5, sg=nil) -> Date [ruby 1.8] <br />
160
132
commercial(cwyear, cweek=1, cwday=1, sg=nil) -> Date [ruby 1.9]
161
133
162
134
CALL_SEQ
163
135
164
- assert_equal expected , method_obj . call_seq
136
+ assert_equal expected , comment . extract_call_seq
165
137
end
166
138
167
139
def test_extract_call_seq_c_separator
@@ -183,10 +155,6 @@ def test_extract_call_seq_c_separator
183
155
184
156
COMMENT
185
157
186
- method_obj = RDoc ::AnyMethod . new nil , 'blah'
187
-
188
- comment . extract_call_seq method_obj
189
-
190
158
expected = <<-CALL_SEQ
191
159
ARGF.readlines(sep=$/) -> array
192
160
ARGF.readlines(limit) -> array
@@ -196,7 +164,7 @@ def test_extract_call_seq_c_separator
196
164
ARGF.to_a(sep, limit) -> array
197
165
CALL_SEQ
198
166
199
- assert_equal expected , method_obj . call_seq
167
+ assert_equal expected , comment . extract_call_seq
200
168
201
169
expected = <<-'COMMENT'
202
170
@@ -211,11 +179,12 @@ def test_extract_call_seq_c_separator
211
179
assert_equal expected , comment . text
212
180
end
213
181
182
+ # This test relies on AnyMethod#call_seq's behaviour as well
214
183
def test_extract_call_linear_performance
215
184
pre = -> ( n ) { [ n , RDoc ::Comment . new ( "\n " *n + 'call-seq:' + 'a' *n ) ] }
216
185
method_obj = RDoc ::AnyMethod . new nil , 'blah'
217
186
assert_linear_performance ( ( 2 ..5 ) . map { |i | 10 **i } , pre : pre ) do |n , comment |
218
- comment . extract_call_seq method_obj
187
+ method_obj . call_seq = comment . extract_call_seq
219
188
assert_equal n , method_obj . call_seq . size
220
189
end
221
190
end
0 commit comments