@@ -41,154 +41,6 @@ def test_equals2
4141 refute_equal @comment , c3
4242 end
4343
44- def test_extract_call_seq
45- comment = RDoc ::Comment . new <<-COMMENT , @top_level
46- call-seq:
47- bla => true or false
48-
49- moar comment
50- COMMENT
51-
52- assert_equal "bla => true or false\n " , comment . extract_call_seq
53- end
54-
55- def test_extract_call_seq_blank
56- comment = RDoc ::Comment . new <<-COMMENT , @top_level
57- call-seq:
58- bla => true or false
59-
60- COMMENT
61-
62- assert_equal "bla => true or false\n " , comment . extract_call_seq
63- end
64-
65- def test_extract_call_seq_commented
66- comment = RDoc ::Comment . new <<-COMMENT , @top_level
67- # call-seq:
68- # bla => true or false
69- #
70- # moar comment
71- COMMENT
72-
73- assert_nil comment . extract_call_seq
74- end
75-
76- def test_extract_call_seq_no_blank
77- comment = RDoc ::Comment . new <<-COMMENT , @top_level
78- call-seq:
79- bla => true or false
80- COMMENT
81-
82- assert_equal "bla => true or false\n " , comment . extract_call_seq
83- end
84-
85- def test_extract_call_seq_undent
86- comment = RDoc ::Comment . new <<-COMMENT , @top_level
87- call-seq:
88- bla => true or false
89- moar comment
90- COMMENT
91-
92- assert_equal "bla => true or false\n moar comment\n " , comment . extract_call_seq
93- end
94-
95- def test_extract_call_seq_c
96- comment = RDoc ::Comment . new <<-COMMENT
97- call-seq:
98- commercial() -> Date <br />
99- commercial(cwyear, cweek=41, cwday=5, sg=nil) -> Date [ruby 1.8] <br />
100- commercial(cwyear, cweek=1, cwday=1, sg=nil) -> Date [ruby 1.9]
101-
102- If no arguments are given:
103- * ruby 1.8: returns a +Date+ for 1582-10-15 (the Day of Calendar Reform in
104- Italy)
105- * ruby 1.9: returns a +Date+ for julian day 0
106-
107- Otherwise, returns a +Date+ for the commercial week year, commercial week,
108- and commercial week day given. Ignores the 4th argument.
109- COMMENT
110-
111- expected = <<-CALL_SEQ . chomp
112- commercial() -> Date <br />
113- commercial(cwyear, cweek=41, cwday=5, sg=nil) -> Date [ruby 1.8] <br />
114- commercial(cwyear, cweek=1, cwday=1, sg=nil) -> Date [ruby 1.9]
115-
116- CALL_SEQ
117-
118- assert_equal expected , comment . extract_call_seq
119- end
120-
121- def test_extract_call_seq_c_no_blank
122- comment = RDoc ::Comment . new <<-COMMENT
123- call-seq:
124- commercial() -> Date <br />
125- commercial(cwyear, cweek=41, cwday=5, sg=nil) -> Date [ruby 1.8] <br />
126- commercial(cwyear, cweek=1, cwday=1, sg=nil) -> Date [ruby 1.9]
127- COMMENT
128-
129- expected = <<-CALL_SEQ . chomp
130- commercial() -> Date <br />
131- commercial(cwyear, cweek=41, cwday=5, sg=nil) -> Date [ruby 1.8] <br />
132- commercial(cwyear, cweek=1, cwday=1, sg=nil) -> Date [ruby 1.9]
133-
134- CALL_SEQ
135-
136- assert_equal expected , comment . extract_call_seq
137- end
138-
139- def test_extract_call_seq_c_separator
140- comment = RDoc ::Comment . new <<-'COMMENT'
141- call-seq:
142- ARGF.readlines(sep=$/) -> array
143- ARGF.readlines(limit) -> array
144- ARGF.readlines(sep, limit) -> array
145-
146- ARGF.to_a(sep=$/) -> array
147- ARGF.to_a(limit) -> array
148- ARGF.to_a(sep, limit) -> array
149-
150- Reads +ARGF+'s current file in its entirety, returning an +Array+ of its
151- lines, one line per element. Lines are assumed to be separated by _sep_.
152-
153- lines = ARGF.readlines
154- lines[0] #=> "This is line one\n"
155-
156- COMMENT
157-
158- expected = <<-CALL_SEQ
159- ARGF.readlines(sep=$/) -> array
160- ARGF.readlines(limit) -> array
161- ARGF.readlines(sep, limit) -> array
162- ARGF.to_a(sep=$/) -> array
163- ARGF.to_a(limit) -> array
164- ARGF.to_a(sep, limit) -> array
165- CALL_SEQ
166-
167- assert_equal expected , comment . extract_call_seq
168-
169- expected = <<-'COMMENT'
170-
171- Reads +ARGF+'s current file in its entirety, returning an +Array+ of its
172- lines, one line per element. Lines are assumed to be separated by _sep_.
173-
174- lines = ARGF.readlines
175- lines[0] #=> "This is line one\n"
176-
177- COMMENT
178-
179- assert_equal expected , comment . text
180- end
181-
182- # This test relies on AnyMethod#call_seq's behaviour as well
183- def test_extract_call_linear_performance
184- pre = -> ( n ) { [ n , RDoc ::Comment . new ( "\n " *n + 'call-seq:' + 'a' *n ) ] }
185- method_obj = RDoc ::AnyMethod . new nil , 'blah'
186- assert_linear_performance ( ( 2 ..5 ) . map { |i | 10 **i } , pre : pre ) do |n , comment |
187- method_obj . call_seq = comment . extract_call_seq
188- assert_equal n , method_obj . call_seq . size
189- end
190- end
191-
19244 def test_force_encoding
19345 @comment = RDoc ::Encoding . change_encoding @comment , Encoding ::UTF_8
19446
@@ -324,159 +176,6 @@ def test_parse_rd
324176 assert_equal expected , c . parse
325177 end
326178
327- def test_remove_private_encoding
328- comment = RDoc ::Comment . new <<-EOS , @top_level
329- # This is text
330- #--
331- # this is private
332- EOS
333-
334- comment = RDoc ::Encoding . change_encoding comment , Encoding ::IBM437
335-
336- comment . remove_private
337-
338- assert_equal Encoding ::IBM437 , comment . text . encoding
339- end
340-
341- def test_remove_private_hash
342- @comment . text = <<-TEXT
343- #--
344- # private
345- #++
346- # public
347- TEXT
348-
349- @comment . remove_private
350-
351- assert_equal "# public\n " , @comment . text
352- end
353-
354- def test_remove_private_hash_trail
355- comment = RDoc ::Comment . new <<-EOS , @top_level
356- # This is text
357- #--
358- # this is private
359- EOS
360-
361- expected = RDoc ::Comment . new <<-EOS , @top_level
362- # This is text
363- EOS
364-
365- comment . remove_private
366-
367- assert_equal expected , comment
368- end
369-
370- def test_remove_private_long
371- comment = RDoc ::Comment . new <<-EOS , @top_level
372- #-----
373- #++
374- # this is text
375- #-----
376- EOS
377-
378- expected = RDoc ::Comment . new <<-EOS , @top_level
379- # this is text
380- EOS
381-
382- comment . remove_private
383-
384- assert_equal expected , comment
385- end
386-
387- def test_remove_private_rule
388- comment = RDoc ::Comment . new <<-EOS , @top_level
389- # This is text with a rule:
390- # ---
391- # this is also text
392- EOS
393-
394- expected = comment . dup
395-
396- comment . remove_private
397-
398- assert_equal expected , comment
399- end
400-
401- def test_remove_private_star
402- @comment . text = <<-TEXT
403- /*
404- *--
405- * private
406- *++
407- * public
408- */
409- TEXT
410-
411- @comment . remove_private
412-
413- assert_equal "/*\n * public\n */\n " , @comment . text
414- end
415-
416- def test_remove_private_star2
417- @comment . text = <<-TEXT
418- /*--
419- * private
420- *++
421- * public
422- */
423- TEXT
424-
425- @comment . remove_private
426-
427- assert_equal "/*--\n * private\n *++\n * public\n */\n " , @comment . text
428- end
429-
430- def test_remove_private_toggle
431- comment = RDoc ::Comment . new <<-EOS , @top_level
432- # This is text
433- #--
434- # this is private
435- #++
436- # This is text again.
437- EOS
438-
439- expected = RDoc ::Comment . new <<-EOS , @top_level
440- # This is text
441- # This is text again.
442- EOS
443-
444- comment . remove_private
445-
446- assert_equal expected , comment
447- end
448-
449- def test_remove_private_toggle_encoding
450- comment = RDoc ::Comment . new <<-EOS , @top_level
451- # This is text
452- #--
453- # this is private
454- #++
455- # This is text again.
456- EOS
457-
458- comment = RDoc ::Encoding . change_encoding comment , Encoding ::IBM437
459-
460- comment . remove_private
461-
462- assert_equal Encoding ::IBM437 , comment . text . encoding
463- end
464-
465- def test_remove_private_toggle_encoding_ruby_bug?
466- comment = RDoc ::Comment . new <<-EOS , @top_level
467- #--
468- # this is private
469- #++
470- # This is text again.
471- EOS
472-
473- comment = RDoc ::Encoding . change_encoding comment , Encoding ::IBM437
474-
475- comment . remove_private
476-
477- assert_equal Encoding ::IBM437 , comment . text . encoding
478- end
479-
480179 def test_parse_directives
481180 comment = <<~COMMENT
482181 comment1
0 commit comments