~ubuntu-branches/ubuntu/quantal/ruby1.9.1/quantal

« back to all changes in this revision

Viewing changes to test/rdoc/test_rdoc_markup_to_rdoc.rb

  • Committer: Bazaar Package Importer
  • Author(s): Lucas Nussbaum
  • Date: 2010-07-31 17:08:39 UTC
  • mfrom: (1.1.4 upstream) (8.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20100731170839-j034dmpdqt1cc4p6
Tags: 1.9.2~svn28788-1
* New release based on upstream snapshot from the 1.9.2 branch,
  after 1.9.2 RC2. That branch is (supposed to be) binary-compatible
  with the 1.9.1 branch.
  + Builds fine on i386. Closes: #580852.
* Upgrade to Standards-Version: 3.9.1. No changes needed.
* Updated generated incs.
* Patches that still need work:
  + Unclear status, need more investigation:
   090729_fix_Makefile_deps.dpatch
   090803_exclude_rdoc.dpatch
   203_adjust_base_of_search_path.dpatch
   902_define_YAML_in_yaml_stringio.rb.dpatch
   919_common.mk_tweaks.dpatch
   931_libruby_suffix.dpatch
   940_test_thread_mutex_sync_shorter.dpatch
  + Maybe not needed anymore, keeping but not applying.
   102_skip_test_copy_stream.dpatch (test doesn't block anymore?)
   104_skip_btest_io.dpatch (test doesn't block anymore?)
   201_gem_prelude.dpatch (we don't use that rubygems anyway?)
   202_gem_default_dir.dpatch (we don't use that rubygems anyway?)
   940_test_file_exhaustive_fails_as_root.dpatch
   940_test_priority_fails.dpatch
   100518_load_libc_libm.dpatch
* Add disable-tests.diff: disable some tests that cause failures on FreeBSD.
  Closes: #590002, #543805, #542927.
* However, many new failures on FreeBSD. Since that version is still an
  improvement, add the check that makes test suite failures non-fatal on
  FreeBSD again. That still needs to be investigated.
* Re-add 903_skip_base_ruby_check.dpatch
* Add build-dependency on ruby1.8 and drop all pre-generated files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require 'rubygems'
 
2
require 'rdoc/markup/formatter_test_case'
 
3
require 'rdoc/markup/to_rdoc'
 
4
require 'minitest/autorun'
 
5
 
 
6
class TestRDocMarkupToRdoc < RDoc::Markup::FormatterTestCase
 
7
 
 
8
  add_visitor_tests
 
9
 
 
10
  def setup
 
11
    super
 
12
 
 
13
    @to = RDoc::Markup::ToRdoc.new
 
14
  end
 
15
 
 
16
  def accept_blank_line
 
17
    assert_equal "\n", @to.res.join
 
18
  end
 
19
 
 
20
  def accept_heading
 
21
    assert_equal "===== Hello\n", @to.res.join
 
22
  end
 
23
 
 
24
  def accept_list_end_bullet
 
25
    assert_empty @to.list_index
 
26
    assert_empty @to.list_type
 
27
    assert_empty @to.list_width
 
28
  end
 
29
 
 
30
  def accept_list_end_label
 
31
    assert_empty @to.list_index
 
32
    assert_empty @to.list_type
 
33
    assert_empty @to.list_width
 
34
  end
 
35
 
 
36
  def accept_list_end_lalpha
 
37
    assert_empty @to.list_index
 
38
    assert_empty @to.list_type
 
39
    assert_empty @to.list_width
 
40
  end
 
41
 
 
42
  def accept_list_end_note
 
43
    assert_empty @to.list_index
 
44
    assert_empty @to.list_type
 
45
    assert_empty @to.list_width
 
46
  end
 
47
 
 
48
  def accept_list_end_number
 
49
    assert_empty @to.list_index
 
50
    assert_empty @to.list_type
 
51
    assert_empty @to.list_width
 
52
  end
 
53
 
 
54
  def accept_list_end_ualpha
 
55
    assert_empty @to.list_index
 
56
    assert_empty @to.list_type
 
57
    assert_empty @to.list_width
 
58
  end
 
59
 
 
60
  def accept_list_item_end_bullet
 
61
    assert_equal 0, @to.indent, 'indent'
 
62
  end
 
63
 
 
64
  def accept_list_item_end_label
 
65
    assert_equal "\n", @to.res.join
 
66
    assert_equal 0, @to.indent, 'indent'
 
67
  end
 
68
 
 
69
  def accept_list_item_end_lalpha
 
70
    assert_equal 0, @to.indent, 'indent'
 
71
    assert_equal 'b', @to.list_index.last
 
72
  end
 
73
 
 
74
  def accept_list_item_end_note
 
75
    assert_equal "\n", @to.res.join
 
76
    assert_equal 0, @to.indent, 'indent'
 
77
  end
 
78
 
 
79
  def accept_list_item_end_number
 
80
    assert_equal 0, @to.indent, 'indent'
 
81
    assert_equal 2, @to.list_index.last
 
82
  end
 
83
 
 
84
  def accept_list_item_end_ualpha
 
85
    assert_equal 0, @to.indent, 'indent'
 
86
    assert_equal 'B', @to.list_index.last
 
87
  end
 
88
 
 
89
  def accept_list_item_start_bullet
 
90
    assert_equal [""], @to.res
 
91
    assert_equal '* ', @to.prefix
 
92
  end
 
93
 
 
94
  def accept_list_item_start_label
 
95
    assert_equal [""], @to.res
 
96
    assert_equal "cat:\n  ", @to.prefix
 
97
 
 
98
    assert_equal 2, @to.indent
 
99
  end
 
100
 
 
101
  def accept_list_item_start_lalpha
 
102
    assert_equal [""], @to.res
 
103
    assert_equal 'a. ', @to.prefix
 
104
 
 
105
    assert_equal 'a', @to.list_index.last
 
106
    assert_equal 3, @to.indent
 
107
  end
 
108
 
 
109
  def accept_list_item_start_note
 
110
    assert_equal [""], @to.res
 
111
    assert_equal "cat:\n  ", @to.prefix
 
112
 
 
113
    assert_equal 2, @to.indent
 
114
  end
 
115
 
 
116
  def accept_list_item_start_number
 
117
    assert_equal [""], @to.res
 
118
    assert_equal '1. ', @to.prefix
 
119
 
 
120
    assert_equal 1, @to.list_index.last
 
121
    assert_equal 3, @to.indent
 
122
  end
 
123
 
 
124
  def accept_list_item_start_ualpha
 
125
    assert_equal [""], @to.res
 
126
    assert_equal 'A. ', @to.prefix
 
127
 
 
128
    assert_equal 'A', @to.list_index.last
 
129
    assert_equal 3, @to.indent
 
130
  end
 
131
 
 
132
  def accept_list_start_bullet
 
133
    assert_equal "",   @to.res.join
 
134
    assert_equal [nil],     @to.list_index
 
135
    assert_equal [:BULLET], @to.list_type
 
136
    assert_equal [1],       @to.list_width
 
137
  end
 
138
 
 
139
  def accept_list_start_label
 
140
    assert_equal "",  @to.res.join
 
141
    assert_equal [nil],    @to.list_index
 
142
    assert_equal [:LABEL], @to.list_type
 
143
    assert_equal [2],      @to.list_width
 
144
  end
 
145
 
 
146
  def accept_list_start_lalpha
 
147
    assert_equal "",   @to.res.join
 
148
    assert_equal ['a'],     @to.list_index
 
149
    assert_equal [:LALPHA], @to.list_type
 
150
    assert_equal [1],       @to.list_width
 
151
  end
 
152
 
 
153
  def accept_list_start_note
 
154
    assert_equal "", @to.res.join
 
155
    assert_equal [nil],   @to.list_index
 
156
    assert_equal [:NOTE], @to.list_type
 
157
    assert_equal [2],     @to.list_width
 
158
  end
 
159
 
 
160
  def accept_list_start_number
 
161
    assert_equal "",   @to.res.join
 
162
    assert_equal [1],       @to.list_index
 
163
    assert_equal [:NUMBER], @to.list_type
 
164
    assert_equal [1],       @to.list_width
 
165
  end
 
166
 
 
167
  def accept_list_start_ualpha
 
168
    assert_equal "",   @to.res.join
 
169
    assert_equal ['A'],     @to.list_index
 
170
    assert_equal [:UALPHA], @to.list_type
 
171
    assert_equal [1],       @to.list_width
 
172
  end
 
173
 
 
174
  def accept_paragraph
 
175
    assert_equal "hi\n", @to.res.join
 
176
  end
 
177
 
 
178
  def accept_raw
 
179
    raw = <<-RAW.rstrip
 
180
<table>
 
181
<tr><th>Name<th>Count
 
182
<tr><td>a<td>1
 
183
<tr><td>b<td>2
 
184
</table>
 
185
    RAW
 
186
 
 
187
    assert_equal raw, @to.res.join
 
188
  end
 
189
 
 
190
  def accept_rule
 
191
    assert_equal "#{'-' * 78}\n", @to.res.join
 
192
  end
 
193
 
 
194
  def accept_verbatim # FormatterTestCase doesn't set indent for ToAnsi
 
195
    assert_equal "  hi\n  world\n\n", @to.res.join
 
196
  end
 
197
 
 
198
  def end_accepting
 
199
    assert_equal "hi", @to.end_accepting
 
200
  end
 
201
 
 
202
  def start_accepting
 
203
    assert_equal 0, @to.indent
 
204
    assert_equal [""], @to.res
 
205
    assert_empty @to.list_index
 
206
    assert_empty @to.list_type
 
207
    assert_empty @to.list_width
 
208
  end
 
209
 
 
210
  def test_accept_heading_1
 
211
    @to.start_accepting
 
212
    @to.accept_heading @RM::Heading.new(1, 'Hello')
 
213
 
 
214
    assert_equal "= Hello\n", @to.end_accepting
 
215
  end
 
216
 
 
217
  def test_accept_heading_2
 
218
    @to.start_accepting
 
219
    @to.accept_heading @RM::Heading.new(2, 'Hello')
 
220
 
 
221
    assert_equal "== Hello\n", @to.end_accepting
 
222
  end
 
223
 
 
224
  def test_accept_heading_3
 
225
    @to.start_accepting
 
226
    @to.accept_heading @RM::Heading.new(3, 'Hello')
 
227
 
 
228
    assert_equal "=== Hello\n", @to.end_accepting
 
229
  end
 
230
 
 
231
  def test_accept_heading_4
 
232
    @to.start_accepting
 
233
    @to.accept_heading @RM::Heading.new(4, 'Hello')
 
234
 
 
235
    assert_equal "==== Hello\n", @to.end_accepting
 
236
  end
 
237
 
 
238
  def test_accept_heading_indent
 
239
    @to.start_accepting
 
240
    @to.indent = 3
 
241
    @to.accept_heading @RM::Heading.new(1, 'Hello')
 
242
 
 
243
    assert_equal "   = Hello\n", @to.end_accepting
 
244
  end
 
245
 
 
246
  def test_accept_heading_b
 
247
    @to.start_accepting
 
248
    @to.indent = 3
 
249
    @to.accept_heading @RM::Heading.new(1, '*Hello*')
 
250
 
 
251
    assert_equal "   = <b>Hello</b>\n", @to.end_accepting
 
252
  end
 
253
 
 
254
  def test_accept_list_item_start_note_2
 
255
    list = @RM::List.new(:NOTE,
 
256
             @RM::ListItem.new('<tt>teletype</tt>',
 
257
                               @RM::Paragraph.new('teletype description')))
 
258
 
 
259
    @to.start_accepting
 
260
 
 
261
    list.accept @to
 
262
 
 
263
    expected = "<tt>teletype</tt>:\n  teletype description\n\n"
 
264
 
 
265
    assert_equal expected, @to.end_accepting
 
266
  end
 
267
 
 
268
  def test_accept_paragraph_b
 
269
    @to.start_accepting
 
270
    @to.accept_paragraph @RM::Paragraph.new('reg <b>bold words</b> reg')
 
271
 
 
272
    expected = "reg <b>bold words</b> reg\n"
 
273
 
 
274
    assert_equal expected, @to.end_accepting
 
275
  end
 
276
 
 
277
  def test_accept_paragraph_i
 
278
    @to.start_accepting
 
279
    @to.accept_paragraph @RM::Paragraph.new('reg <em>italic words</em> reg')
 
280
 
 
281
    expected = "reg <em>italic words</em> reg\n"
 
282
 
 
283
    assert_equal expected, @to.end_accepting
 
284
  end
 
285
 
 
286
  def test_accept_paragraph_indent
 
287
    @to.start_accepting
 
288
    @to.indent = 3
 
289
    @to.accept_paragraph @RM::Paragraph.new('words ' * 30)
 
290
 
 
291
    expected = <<-EXPECTED
 
292
   words words words words words words words words words words words words
 
293
   words words words words words words words words words words words words
 
294
   words words words words words words 
 
295
    EXPECTED
 
296
 
 
297
    assert_equal expected, @to.end_accepting
 
298
  end
 
299
 
 
300
  def test_accept_paragraph_plus
 
301
    @to.start_accepting
 
302
    @to.accept_paragraph @RM::Paragraph.new('regular +teletype+ regular')
 
303
 
 
304
    expected = "regular <tt>teletype</tt> regular\n"
 
305
 
 
306
    assert_equal expected, @to.end_accepting
 
307
  end
 
308
 
 
309
  def test_accept_paragraph_star
 
310
    @to.start_accepting
 
311
    @to.accept_paragraph @RM::Paragraph.new('regular *bold* regular')
 
312
 
 
313
    expected = "regular <b>bold</b> regular\n"
 
314
 
 
315
    assert_equal expected, @to.end_accepting
 
316
  end
 
317
 
 
318
  def test_accept_paragraph_underscore
 
319
    @to.start_accepting
 
320
    @to.accept_paragraph @RM::Paragraph.new('regular _italic_ regular')
 
321
 
 
322
    expected = "regular <em>italic</em> regular\n"
 
323
 
 
324
    assert_equal expected, @to.end_accepting
 
325
  end
 
326
 
 
327
  def test_accept_paragraph_wrap
 
328
    @to.start_accepting
 
329
    @to.accept_paragraph @RM::Paragraph.new('words ' * 30)
 
330
 
 
331
    expected = <<-EXPECTED
 
332
words words words words words words words words words words words words words
 
333
words words words words words words words words words words words words words
 
334
words words words words 
 
335
    EXPECTED
 
336
 
 
337
    assert_equal expected, @to.end_accepting
 
338
  end
 
339
 
 
340
  def test_accept_rule_indent
 
341
    @to.start_accepting
 
342
    @to.indent = 3
 
343
 
 
344
    @to.accept_rule @RM::Rule.new(1)
 
345
 
 
346
    assert_equal "   #{'-' * 75}\n", @to.end_accepting
 
347
  end
 
348
 
 
349
  def test_accept_verbatim_indent
 
350
    @to.start_accepting
 
351
 
 
352
    @to.indent = 2
 
353
 
 
354
    @to.accept_verbatim @RM::Verbatim.new('    ', 'hi', "\n",
 
355
                                          '     ', 'world', "\n")
 
356
 
 
357
    assert_equal "    hi\n     world\n\n", @to.end_accepting
 
358
  end
 
359
 
 
360
  def test_accept_verbatim_big_indent
 
361
    @to.start_accepting
 
362
 
 
363
    @to.indent = 2
 
364
 
 
365
    @to.accept_verbatim @RM::Verbatim.new('    ', 'hi', "\n",
 
366
                                          '    ', 'world', "\n")
 
367
 
 
368
    assert_equal "    hi\n    world\n\n", @to.end_accepting
 
369
  end
 
370
 
 
371
  def test_attributes
 
372
    assert_equal 'Dog', @to.attributes("\\Dog")
 
373
  end
 
374
 
 
375
  def test_list_nested
 
376
    doc = @RM::Document.new(
 
377
            @RM::List.new(:BULLET,
 
378
              @RM::ListItem.new(nil,
 
379
                @RM::Paragraph.new('l1'),
 
380
                @RM::List.new(:BULLET,
 
381
                  @RM::ListItem.new(nil,
 
382
                    @RM::Paragraph.new('l1.1')))),
 
383
              @RM::ListItem.new(nil,
 
384
                @RM::Paragraph.new('l2'))))
 
385
 
 
386
    output = doc.accept @to
 
387
 
 
388
    expected = <<-EXPECTED
 
389
* l1
 
390
  * l1.1
 
391
* l2
 
392
    EXPECTED
 
393
 
 
394
    assert_equal expected, output
 
395
  end
 
396
 
 
397
  def test_list_verbatim # HACK overblown
 
398
    doc = @RM::Document.new(
 
399
            @RM::List.new(:BULLET,
 
400
              @RM::ListItem.new(nil,
 
401
                @RM::Paragraph.new('list', 'stuff'),
 
402
                @RM::BlankLine.new(),
 
403
                @RM::Verbatim.new('   ', '*', ' ', 'list', "\n",
 
404
                                  '     ', 'with', "\n",
 
405
                                  "\n",
 
406
                                  '     ', 'second', "\n",
 
407
                                  "\n",
 
408
                                  '     ', '1.', ' ', 'indented', "\n",
 
409
                                  '     ', '2.', ' ', 'numbered', "\n",
 
410
                                  "\n",
 
411
                                  '     ', 'third', "\n",
 
412
                                  "\n",
 
413
                                  '   ', '*', ' ', 'second', "\n"))))
 
414
 
 
415
    output = doc.accept @to
 
416
 
 
417
    expected = <<-EXPECTED
 
418
* list stuff
 
419
 
 
420
    * list
 
421
      with
 
422
 
 
423
      second
 
424
 
 
425
      1. indented
 
426
      2. numbered
 
427
 
 
428
      third
 
429
 
 
430
    * second
 
431
 
 
432
    EXPECTED
 
433
 
 
434
    assert_equal expected, output
 
435
  end
 
436
 
 
437
end
 
438