rack-auth-ip 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (20) hide show
  1. data/ChangeLog +12 -0
  2. data/Rakefile +6 -1
  3. data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-block_rb.html +1 -1
  4. data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-callbacks_rb.html +1 -1
  5. data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-change_rb.html +1 -1
  6. data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-hunk_rb.html +1 -1
  7. data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs_rb.html +1 -1
  8. data/doc/output/coverage/-Library-Ruby-Gems-gems-ipaddr_list-0_0_2-lib-ipaddr_list_rb.html +794 -0
  9. data/doc/output/coverage/-Library-Ruby-Gems-gems-rcov-0_8_1_2_0-lib-rcov_rb.html +1 -1
  10. data/doc/output/coverage/index.html +33 -195
  11. data/doc/output/coverage/lib-rack-auth-ip_rb.html +63 -62
  12. data/lib/rack/auth/ip.rb +4 -3
  13. metadata +12 -9
  14. data/doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-drb-drb_rb.html +0 -2373
  15. data/doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-drb-eq_rb.html +0 -626
  16. data/doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-drb-invokemethod_rb.html +0 -646
  17. data/doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-ipaddr_rb.html +0 -1139
  18. data/doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-pp_rb.html +0 -1257
  19. data/doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-prettyprint_rb.html +0 -1506
  20. data/doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-timeout_rb.html +0 -715
@@ -1,1506 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
- <html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'><head><title>/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/prettyprint.rb - C0 code coverage information</title>
3
- <style type='text/css'>body { background-color: rgb(240, 240, 245); }</style>
4
- <style type='text/css'>span.cross-ref-title {
5
- font-size: 140%;
6
- }
7
- span.cross-ref a {
8
- text-decoration: none;
9
- }
10
- span.cross-ref {
11
- background-color:#f3f7fa;
12
- border: 1px dashed #333;
13
- margin: 1em;
14
- padding: 0.5em;
15
- overflow: hidden;
16
- }
17
- a.crossref-toggle {
18
- text-decoration: none;
19
- }
20
- span.marked0 {
21
- background-color: rgb(185, 210, 200);
22
- display: block;
23
- }
24
- span.marked1 {
25
- background-color: rgb(190, 215, 205);
26
- display: block;
27
- }
28
- span.inferred0 {
29
- background-color: rgb(175, 200, 200);
30
- display: block;
31
- }
32
- span.inferred1 {
33
- background-color: rgb(180, 205, 205);
34
- display: block;
35
- }
36
- span.uncovered0 {
37
- background-color: rgb(225, 110, 110);
38
- display: block;
39
- }
40
- span.uncovered1 {
41
- background-color: rgb(235, 120, 120);
42
- display: block;
43
- }
44
- span.overview {
45
- border-bottom: 8px solid black;
46
- }
47
- div.overview {
48
- border-bottom: 8px solid black;
49
- }
50
- body {
51
- font-family: verdana, arial, helvetica;
52
- }
53
- div.footer {
54
- font-size: 68%;
55
- margin-top: 1.5em;
56
- }
57
- h1, h2, h3, h4, h5, h6 {
58
- margin-bottom: 0.5em;
59
- }
60
- h5 {
61
- margin-top: 0.5em;
62
- }
63
- .hidden {
64
- display: none;
65
- }
66
- div.separator {
67
- height: 10px;
68
- }
69
- /* Commented out for better readability, esp. on IE */
70
- /*
71
- table tr td, table tr th {
72
- font-size: 68%;
73
- }
74
- td.value table tr td {
75
- font-size: 11px;
76
- }
77
- */
78
- table.percent_graph {
79
- height: 12px;
80
- border: #808080 1px solid;
81
- empty-cells: show;
82
- }
83
- table.percent_graph td.covered {
84
- height: 10px;
85
- background: #00f000;
86
- }
87
- table.percent_graph td.uncovered {
88
- height: 10px;
89
- background: #e00000;
90
- }
91
- table.percent_graph td.NA {
92
- height: 10px;
93
- background: #eaeaea;
94
- }
95
- table.report {
96
- border-collapse: collapse;
97
- width: 100%;
98
- }
99
- table.report td.heading {
100
- background: #dcecff;
101
- border: #d0d0d0 1px solid;
102
- font-weight: bold;
103
- text-align: center;
104
- }
105
- table.report td.heading:hover {
106
- background: #c0ffc0;
107
- }
108
- table.report td.text {
109
- border: #d0d0d0 1px solid;
110
- }
111
- table.report td.value,
112
- table.report td.lines_total,
113
- table.report td.lines_code {
114
- text-align: right;
115
- border: #d0d0d0 1px solid;
116
- }
117
- table.report tr.light {
118
- background-color: rgb(240, 240, 245);
119
- }
120
- table.report tr.dark {
121
- background-color: rgb(230, 230, 235);
122
- }
123
- </style>
124
- <script type='text/javascript'>
125
- // <![CDATA[
126
- function toggleCode( id ) {
127
- if ( document.getElementById )
128
- elem = document.getElementById( id );
129
- else if ( document.all )
130
- elem = eval( "document.all." + id );
131
- else
132
- return false;
133
-
134
- elemStyle = elem.style;
135
-
136
- if ( elemStyle.display != "block" ) {
137
- elemStyle.display = "block"
138
- } else {
139
- elemStyle.display = "none"
140
- }
141
-
142
- return true;
143
- }
144
-
145
- // Make cross-references hidden by default
146
- document.writeln( "<style type=\"text/css\">span.cross-ref { display: none }</style>" )
147
- // ]]>
148
- </script>
149
- <style type='text/css'>span.run0 {
150
- background-color: rgb(178, 204, 255);
151
- display: block;
152
- }
153
- span.run1 {
154
- background-color: rgb(178, 206, 255);
155
- display: block;
156
- }
157
- span.run2 {
158
- background-color: rgb(178, 209, 255);
159
- display: block;
160
- }
161
- span.run3 {
162
- background-color: rgb(178, 211, 255);
163
- display: block;
164
- }
165
- span.run4 {
166
- background-color: rgb(178, 214, 255);
167
- display: block;
168
- }
169
- span.run5 {
170
- background-color: rgb(178, 218, 255);
171
- display: block;
172
- }
173
- span.run6 {
174
- background-color: rgb(178, 220, 255);
175
- display: block;
176
- }
177
- span.run7 {
178
- background-color: rgb(178, 223, 255);
179
- display: block;
180
- }
181
- span.run8 {
182
- background-color: rgb(178, 225, 255);
183
- display: block;
184
- }
185
- span.run9 {
186
- background-color: rgb(178, 228, 255);
187
- display: block;
188
- }
189
- span.run10 {
190
- background-color: rgb(178, 232, 255);
191
- display: block;
192
- }
193
- span.run11 {
194
- background-color: rgb(178, 234, 255);
195
- display: block;
196
- }
197
- span.run12 {
198
- background-color: rgb(178, 237, 255);
199
- display: block;
200
- }
201
- span.run13 {
202
- background-color: rgb(178, 239, 255);
203
- display: block;
204
- }
205
- span.run14 {
206
- background-color: rgb(178, 242, 255);
207
- display: block;
208
- }
209
- span.run15 {
210
- background-color: rgb(178, 246, 255);
211
- display: block;
212
- }
213
- span.run16 {
214
- background-color: rgb(178, 248, 255);
215
- display: block;
216
- }
217
- span.run17 {
218
- background-color: rgb(178, 251, 255);
219
- display: block;
220
- }
221
- span.run18 {
222
- background-color: rgb(178, 253, 255);
223
- display: block;
224
- }
225
- span.run19 {
226
- background-color: rgb(178, 255, 253);
227
- display: block;
228
- }
229
- span.run20 {
230
- background-color: rgb(178, 255, 249);
231
- display: block;
232
- }
233
- span.run21 {
234
- background-color: rgb(178, 255, 247);
235
- display: block;
236
- }
237
- span.run22 {
238
- background-color: rgb(178, 255, 244);
239
- display: block;
240
- }
241
- span.run23 {
242
- background-color: rgb(178, 255, 242);
243
- display: block;
244
- }
245
- span.run24 {
246
- background-color: rgb(178, 255, 239);
247
- display: block;
248
- }
249
- span.run25 {
250
- background-color: rgb(178, 255, 235);
251
- display: block;
252
- }
253
- span.run26 {
254
- background-color: rgb(178, 255, 233);
255
- display: block;
256
- }
257
- span.run27 {
258
- background-color: rgb(178, 255, 230);
259
- display: block;
260
- }
261
- span.run28 {
262
- background-color: rgb(178, 255, 228);
263
- display: block;
264
- }
265
- span.run29 {
266
- background-color: rgb(178, 255, 225);
267
- display: block;
268
- }
269
- span.run30 {
270
- background-color: rgb(178, 255, 221);
271
- display: block;
272
- }
273
- span.run31 {
274
- background-color: rgb(178, 255, 219);
275
- display: block;
276
- }
277
- span.run32 {
278
- background-color: rgb(178, 255, 216);
279
- display: block;
280
- }
281
- span.run33 {
282
- background-color: rgb(178, 255, 214);
283
- display: block;
284
- }
285
- span.run34 {
286
- background-color: rgb(178, 255, 211);
287
- display: block;
288
- }
289
- span.run35 {
290
- background-color: rgb(178, 255, 207);
291
- display: block;
292
- }
293
- span.run36 {
294
- background-color: rgb(178, 255, 205);
295
- display: block;
296
- }
297
- span.run37 {
298
- background-color: rgb(178, 255, 202);
299
- display: block;
300
- }
301
- span.run38 {
302
- background-color: rgb(178, 255, 200);
303
- display: block;
304
- }
305
- span.run39 {
306
- background-color: rgb(178, 255, 197);
307
- display: block;
308
- }
309
- span.run40 {
310
- background-color: rgb(178, 255, 193);
311
- display: block;
312
- }
313
- span.run41 {
314
- background-color: rgb(178, 255, 191);
315
- display: block;
316
- }
317
- span.run42 {
318
- background-color: rgb(178, 255, 188);
319
- display: block;
320
- }
321
- span.run43 {
322
- background-color: rgb(178, 255, 186);
323
- display: block;
324
- }
325
- span.run44 {
326
- background-color: rgb(178, 255, 183);
327
- display: block;
328
- }
329
- span.run45 {
330
- background-color: rgb(178, 255, 179);
331
- display: block;
332
- }
333
- span.run46 {
334
- background-color: rgb(179, 255, 178);
335
- display: block;
336
- }
337
- span.run47 {
338
- background-color: rgb(182, 255, 178);
339
- display: block;
340
- }
341
- span.run48 {
342
- background-color: rgb(184, 255, 178);
343
- display: block;
344
- }
345
- span.run49 {
346
- background-color: rgb(187, 255, 178);
347
- display: block;
348
- }
349
- span.run50 {
350
- background-color: rgb(191, 255, 178);
351
- display: block;
352
- }
353
- span.run51 {
354
- background-color: rgb(193, 255, 178);
355
- display: block;
356
- }
357
- span.run52 {
358
- background-color: rgb(196, 255, 178);
359
- display: block;
360
- }
361
- span.run53 {
362
- background-color: rgb(198, 255, 178);
363
- display: block;
364
- }
365
- span.run54 {
366
- background-color: rgb(201, 255, 178);
367
- display: block;
368
- }
369
- span.run55 {
370
- background-color: rgb(205, 255, 178);
371
- display: block;
372
- }
373
- span.run56 {
374
- background-color: rgb(207, 255, 178);
375
- display: block;
376
- }
377
- span.run57 {
378
- background-color: rgb(210, 255, 178);
379
- display: block;
380
- }
381
- span.run58 {
382
- background-color: rgb(212, 255, 178);
383
- display: block;
384
- }
385
- span.run59 {
386
- background-color: rgb(215, 255, 178);
387
- display: block;
388
- }
389
- span.run60 {
390
- background-color: rgb(219, 255, 178);
391
- display: block;
392
- }
393
- span.run61 {
394
- background-color: rgb(221, 255, 178);
395
- display: block;
396
- }
397
- span.run62 {
398
- background-color: rgb(224, 255, 178);
399
- display: block;
400
- }
401
- span.run63 {
402
- background-color: rgb(226, 255, 178);
403
- display: block;
404
- }
405
- span.run64 {
406
- background-color: rgb(229, 255, 178);
407
- display: block;
408
- }
409
- span.run65 {
410
- background-color: rgb(233, 255, 178);
411
- display: block;
412
- }
413
- span.run66 {
414
- background-color: rgb(235, 255, 178);
415
- display: block;
416
- }
417
- span.run67 {
418
- background-color: rgb(238, 255, 178);
419
- display: block;
420
- }
421
- span.run68 {
422
- background-color: rgb(240, 255, 178);
423
- display: block;
424
- }
425
- span.run69 {
426
- background-color: rgb(243, 255, 178);
427
- display: block;
428
- }
429
- span.run70 {
430
- background-color: rgb(247, 255, 178);
431
- display: block;
432
- }
433
- span.run71 {
434
- background-color: rgb(249, 255, 178);
435
- display: block;
436
- }
437
- span.run72 {
438
- background-color: rgb(252, 255, 178);
439
- display: block;
440
- }
441
- span.run73 {
442
- background-color: rgb(255, 255, 178);
443
- display: block;
444
- }
445
- span.run74 {
446
- background-color: rgb(255, 252, 178);
447
- display: block;
448
- }
449
- span.run75 {
450
- background-color: rgb(255, 248, 178);
451
- display: block;
452
- }
453
- span.run76 {
454
- background-color: rgb(255, 246, 178);
455
- display: block;
456
- }
457
- span.run77 {
458
- background-color: rgb(255, 243, 178);
459
- display: block;
460
- }
461
- span.run78 {
462
- background-color: rgb(255, 240, 178);
463
- display: block;
464
- }
465
- span.run79 {
466
- background-color: rgb(255, 238, 178);
467
- display: block;
468
- }
469
- span.run80 {
470
- background-color: rgb(255, 234, 178);
471
- display: block;
472
- }
473
- span.run81 {
474
- background-color: rgb(255, 232, 178);
475
- display: block;
476
- }
477
- span.run82 {
478
- background-color: rgb(255, 229, 178);
479
- display: block;
480
- }
481
- span.run83 {
482
- background-color: rgb(255, 226, 178);
483
- display: block;
484
- }
485
- span.run84 {
486
- background-color: rgb(255, 224, 178);
487
- display: block;
488
- }
489
- span.run85 {
490
- background-color: rgb(255, 220, 178);
491
- display: block;
492
- }
493
- span.run86 {
494
- background-color: rgb(255, 218, 178);
495
- display: block;
496
- }
497
- span.run87 {
498
- background-color: rgb(255, 215, 178);
499
- display: block;
500
- }
501
- span.run88 {
502
- background-color: rgb(255, 212, 178);
503
- display: block;
504
- }
505
- span.run89 {
506
- background-color: rgb(255, 210, 178);
507
- display: block;
508
- }
509
- span.run90 {
510
- background-color: rgb(255, 206, 178);
511
- display: block;
512
- }
513
- span.run91 {
514
- background-color: rgb(255, 204, 178);
515
- display: block;
516
- }
517
- span.run92 {
518
- background-color: rgb(255, 201, 178);
519
- display: block;
520
- }
521
- span.run93 {
522
- background-color: rgb(255, 198, 178);
523
- display: block;
524
- }
525
- span.run94 {
526
- background-color: rgb(255, 196, 178);
527
- display: block;
528
- }
529
- span.run95 {
530
- background-color: rgb(255, 192, 178);
531
- display: block;
532
- }
533
- span.run96 {
534
- background-color: rgb(255, 189, 178);
535
- display: block;
536
- }
537
- span.run97 {
538
- background-color: rgb(255, 187, 178);
539
- display: block;
540
- }
541
- span.run98 {
542
- background-color: rgb(255, 184, 178);
543
- display: block;
544
- }
545
- span.run99 {
546
- background-color: rgb(255, 182, 178);
547
- display: block;
548
- }
549
- span.run100 {
550
- background-color: rgb(255, 178, 178);
551
- display: block;
552
- }
553
- </style>
554
- </head>
555
- <body><h3>C0 code coverage information</h3>
556
- <p>Generated on Sat Jun 28 12:48:58 +0900 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
557
- </p>
558
- <hr/>
559
- <pre><span class='marked0'>Code reported as executed by Ruby looks like this...
560
- </span><span class='marked1'>and this: this line is also marked as covered.
561
- </span><span class='inferred0'>Lines considered as run by rcov, but not reported by Ruby, look like this,
562
- </span><span class='inferred1'>and this: these lines were inferred by rcov (using simple heuristics).
563
- </span><span class='uncovered0'>Finally, here&apos;s a line marked as not executed.
564
- </span></pre>
565
- <table class='report'><thead><tr><td class='heading'>Name</td>
566
- <td class='heading'>Total lines</td>
567
- <td class='heading'>Lines of code</td>
568
- <td class='heading'>Total coverage</td>
569
- <td class='heading'>Code coverage</td>
570
- </tr>
571
- </thead>
572
- <tbody><tr class='light'><td><a href='-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-prettyprint_rb.html'>/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/prettyprint.rb</a>
573
- </td>
574
- <td class='lines_total'><tt>896</tt>
575
- </td>
576
- <td class='lines_code'><tt>706</tt>
577
- </td>
578
- <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>21.0%</tt>
579
- &nbsp;</td>
580
- <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='21'/>
581
- <td class='uncovered' width='79'/>
582
- </tr>
583
- </table>
584
- </td>
585
- </tr>
586
- </table>
587
- </td>
588
- <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>6.5%</tt>
589
- &nbsp;</td>
590
- <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='7'/>
591
- <td class='uncovered' width='93'/>
592
- </tr>
593
- </table>
594
- </td>
595
- </tr>
596
- </table>
597
- </td>
598
- </tr>
599
- </tbody>
600
- </table>
601
- <pre><span class="inferred0"><a name="line1"></a> 1 # $Id$
602
- </span><span class="inferred1"><a name="line2"></a> 2
603
- </span><span class="inferred0"><a name="line3"></a> 3 # This class implements a pretty printing algorithm. It finds line breaks and
604
- </span><span class="inferred1"><a name="line4"></a> 4 # nice indentations for grouped structure.
605
- </span><span class="inferred0"><a name="line5"></a> 5 #
606
- </span><span class="inferred1"><a name="line6"></a> 6 # By default, the class assumes that primitive elements are strings and each
607
- </span><span class="inferred0"><a name="line7"></a> 7 # byte in the strings have single column in width. But it can be used for
608
- </span><span class="inferred1"><a name="line8"></a> 8 # other situations by giving suitable arguments for some methods:
609
- </span><span class="inferred0"><a name="line9"></a> 9 # * newline object and space generation block for PrettyPrint.new
610
- </span><span class="inferred1"><a name="line10"></a> 10 # * optional width argument for PrettyPrint#text
611
- </span><span class="inferred0"><a name="line11"></a> 11 # * PrettyPrint#breakable
612
- </span><span class="inferred1"><a name="line12"></a> 12 #
613
- </span><span class="inferred0"><a name="line13"></a> 13 # There are several candidate uses:
614
- </span><span class="inferred1"><a name="line14"></a> 14 # * text formatting using proportional fonts
615
- </span><span class="inferred0"><a name="line15"></a> 15 # * multibyte characters which has columns different to number of bytes
616
- </span><span class="inferred1"><a name="line16"></a> 16 # * non-string formatting
617
- </span><span class="inferred0"><a name="line17"></a> 17 #
618
- </span><span class="inferred1"><a name="line18"></a> 18 # == Bugs
619
- </span><span class="inferred0"><a name="line19"></a> 19 # * Box based formatting?
620
- </span><span class="inferred1"><a name="line20"></a> 20 # * Other (better) model/algorithm?
621
- </span><span class="inferred0"><a name="line21"></a> 21 #
622
- </span><span class="inferred1"><a name="line22"></a> 22 # == References
623
- </span><span class="inferred0"><a name="line23"></a> 23 # Christian Lindig, Strictly Pretty, March 2000,
624
- </span><span class="inferred1"><a name="line24"></a> 24 # http://www.st.cs.uni-sb.de/~lindig/papers/#pretty
625
- </span><span class="inferred0"><a name="line25"></a> 25 #
626
- </span><span class="inferred1"><a name="line26"></a> 26 # Philip Wadler, A prettier printer, March 1998,
627
- </span><span class="inferred0"><a name="line27"></a> 27 # http://homepages.inf.ed.ac.uk/wadler/topics/language-design.html#prettier
628
- </span><span class="inferred1"><a name="line28"></a> 28 #
629
- </span><span class="inferred0"><a name="line29"></a> 29 # == Author
630
- </span><span class="inferred1"><a name="line30"></a> 30 # Tanaka Akira &lt;akr@m17n.org&gt;
631
- </span><span class="inferred0"><a name="line31"></a> 31 #
632
- </span><span class="marked1"><a name="line32"></a> 32 class PrettyPrint
633
- </span><span class="inferred0"><a name="line33"></a> 33
634
- </span><span class="inferred1"><a name="line34"></a> 34 # This is a convenience method which is same as follows:
635
- </span><span class="inferred0"><a name="line35"></a> 35 #
636
- </span><span class="inferred1"><a name="line36"></a> 36 # begin
637
- </span><span class="inferred0"><a name="line37"></a> 37 # q = PrettyPrint.new(output, maxwidth, newline, &amp;genspace)
638
- </span><span class="inferred1"><a name="line38"></a> 38 # ...
639
- </span><span class="inferred0"><a name="line39"></a> 39 # q.flush
640
- </span><span class="inferred1"><a name="line40"></a> 40 # output
641
- </span><span class="inferred0"><a name="line41"></a> 41 # end
642
- </span><span class="inferred1"><a name="line42"></a> 42 #
643
- </span><span class="marked0"><a name="line43"></a> 43 def PrettyPrint.format(output='', maxwidth=79, newline=&quot;\n&quot;, genspace=lambda {|n| ' ' * n})
644
- </span><span class="uncovered1"><a name="line44"></a> 44 q = PrettyPrint.new(output, maxwidth, newline, &amp;genspace)
645
- </span><span class="uncovered0"><a name="line45"></a> 45 yield q
646
- </span><span class="uncovered1"><a name="line46"></a> 46 q.flush
647
- </span><span class="uncovered0"><a name="line47"></a> 47 output
648
- </span><span class="uncovered1"><a name="line48"></a> 48 end
649
- </span><span class="inferred0"><a name="line49"></a> 49
650
- </span><span class="inferred1"><a name="line50"></a> 50 # This is similar to PrettyPrint::format but the result has no breaks.
651
- </span><span class="inferred0"><a name="line51"></a> 51 #
652
- </span><span class="inferred1"><a name="line52"></a> 52 # +maxwidth+, +newline+ and +genspace+ are ignored.
653
- </span><span class="inferred0"><a name="line53"></a> 53 #
654
- </span><span class="inferred1"><a name="line54"></a> 54 # The invocation of +breakable+ in the block doesn't break a line and is
655
- </span><span class="inferred0"><a name="line55"></a> 55 # treated as just an invocation of +text+.
656
- </span><span class="inferred1"><a name="line56"></a> 56 #
657
- </span><span class="marked0"><a name="line57"></a> 57 def PrettyPrint.singleline_format(output='', maxwidth=nil, newline=nil, genspace=nil)
658
- </span><span class="uncovered1"><a name="line58"></a> 58 q = SingleLine.new(output)
659
- </span><span class="uncovered0"><a name="line59"></a> 59 yield q
660
- </span><span class="uncovered1"><a name="line60"></a> 60 output
661
- </span><span class="uncovered0"><a name="line61"></a> 61 end
662
- </span><span class="inferred1"><a name="line62"></a> 62
663
- </span><span class="inferred0"><a name="line63"></a> 63 # Creates a buffer for pretty printing.
664
- </span><span class="inferred1"><a name="line64"></a> 64 #
665
- </span><span class="inferred0"><a name="line65"></a> 65 # +output+ is an output target. If it is not specified, '' is assumed. It
666
- </span><span class="inferred1"><a name="line66"></a> 66 # should have a &lt;&lt; method which accepts the first argument +obj+ of
667
- </span><span class="inferred0"><a name="line67"></a> 67 # PrettyPrint#text, the first argument +sep+ of PrettyPrint#breakable, the
668
- </span><span class="inferred1"><a name="line68"></a> 68 # first argument +newline+ of PrettyPrint.new, and the result of a given
669
- </span><span class="inferred0"><a name="line69"></a> 69 # block for PrettyPrint.new.
670
- </span><span class="inferred1"><a name="line70"></a> 70 #
671
- </span><span class="inferred0"><a name="line71"></a> 71 # +maxwidth+ specifies maximum line length. If it is not specified, 79 is
672
- </span><span class="inferred1"><a name="line72"></a> 72 # assumed. However actual outputs may overflow +maxwidth+ if long
673
- </span><span class="inferred0"><a name="line73"></a> 73 # non-breakable texts are provided.
674
- </span><span class="inferred1"><a name="line74"></a> 74 #
675
- </span><span class="inferred0"><a name="line75"></a> 75 # +newline+ is used for line breaks. &quot;\n&quot; is used if it is not specified.
676
- </span><span class="inferred1"><a name="line76"></a> 76 #
677
- </span><span class="inferred0"><a name="line77"></a> 77 # The block is used to generate spaces. {|width| ' ' * width} is used if it
678
- </span><span class="inferred1"><a name="line78"></a> 78 # is not given.
679
- </span><span class="inferred0"><a name="line79"></a> 79 #
680
- </span><span class="marked1"><a name="line80"></a> 80 def initialize(output='', maxwidth=79, newline=&quot;\n&quot;, &amp;genspace)
681
- </span><span class="uncovered0"><a name="line81"></a> 81 @output = output
682
- </span><span class="uncovered1"><a name="line82"></a> 82 @maxwidth = maxwidth
683
- </span><span class="uncovered0"><a name="line83"></a> 83 @newline = newline
684
- </span><span class="uncovered1"><a name="line84"></a> 84 @genspace = genspace || lambda {|n| ' ' * n}
685
- </span><span class="uncovered0"><a name="line85"></a> 85
686
- </span><span class="uncovered1"><a name="line86"></a> 86 @output_width = 0
687
- </span><span class="uncovered0"><a name="line87"></a> 87 @buffer_width = 0
688
- </span><span class="uncovered1"><a name="line88"></a> 88 @buffer = []
689
- </span><span class="uncovered0"><a name="line89"></a> 89
690
- </span><span class="uncovered1"><a name="line90"></a> 90 root_group = Group.new(0)
691
- </span><span class="uncovered0"><a name="line91"></a> 91 @group_stack = [root_group]
692
- </span><span class="uncovered1"><a name="line92"></a> 92 @group_queue = GroupQueue.new(root_group)
693
- </span><span class="uncovered0"><a name="line93"></a> 93 @indent = 0
694
- </span><span class="uncovered1"><a name="line94"></a> 94 end
695
- </span><span class="marked0"><a name="line95"></a> 95 attr_reader :output, :maxwidth, :newline, :genspace
696
- </span><span class="marked1"><a name="line96"></a> 96 attr_reader :indent, :group_queue
697
- </span><span class="inferred0"><a name="line97"></a> 97
698
- </span><span class="marked1"><a name="line98"></a> 98 def current_group
699
- </span><span class="uncovered0"><a name="line99"></a> 99 @group_stack.last
700
- </span><span class="uncovered1"><a name="line100"></a>100 end
701
- </span><span class="inferred0"><a name="line101"></a>101
702
- </span><span class="inferred1"><a name="line102"></a>102 # first? is a predicate to test the call is a first call to first? with
703
- </span><span class="inferred0"><a name="line103"></a>103 # current group.
704
- </span><span class="inferred1"><a name="line104"></a>104 #
705
- </span><span class="inferred0"><a name="line105"></a>105 # It is useful to format comma separated values as:
706
- </span><span class="inferred1"><a name="line106"></a>106 #
707
- </span><span class="inferred0"><a name="line107"></a>107 # q.group(1, '[', ']') {
708
- </span><span class="inferred1"><a name="line108"></a>108 # xxx.each {|yyy|
709
- </span><span class="inferred0"><a name="line109"></a>109 # unless q.first?
710
- </span><span class="inferred1"><a name="line110"></a>110 # q.text ','
711
- </span><span class="inferred0"><a name="line111"></a>111 # q.breakable
712
- </span><span class="inferred1"><a name="line112"></a>112 # end
713
- </span><span class="inferred0"><a name="line113"></a>113 # ... pretty printing yyy ...
714
- </span><span class="inferred1"><a name="line114"></a>114 # }
715
- </span><span class="inferred0"><a name="line115"></a>115 # }
716
- </span><span class="inferred1"><a name="line116"></a>116 #
717
- </span><span class="inferred0"><a name="line117"></a>117 # first? is obsoleted in 1.8.2.
718
- </span><span class="inferred1"><a name="line118"></a>118 #
719
- </span><span class="marked0"><a name="line119"></a>119 def first?
720
- </span><span class="uncovered1"><a name="line120"></a>120 warn &quot;PrettyPrint#first? is obsoleted at 1.8.2.&quot;
721
- </span><span class="uncovered0"><a name="line121"></a>121 current_group.first?
722
- </span><span class="uncovered1"><a name="line122"></a>122 end
723
- </span><span class="inferred0"><a name="line123"></a>123
724
- </span><span class="marked1"><a name="line124"></a>124 def break_outmost_groups
725
- </span><span class="uncovered0"><a name="line125"></a>125 while @maxwidth &lt; @output_width + @buffer_width
726
- </span><span class="uncovered1"><a name="line126"></a>126 return unless group = @group_queue.deq
727
- </span><span class="uncovered0"><a name="line127"></a>127 until group.breakables.empty?
728
- </span><span class="uncovered1"><a name="line128"></a>128 data = @buffer.shift
729
- </span><span class="uncovered0"><a name="line129"></a>129 @output_width = data.output(@output, @output_width)
730
- </span><span class="uncovered1"><a name="line130"></a>130 @buffer_width -= data.width
731
- </span><span class="uncovered0"><a name="line131"></a>131 end
732
- </span><span class="uncovered1"><a name="line132"></a>132 while !@buffer.empty? &amp;&amp; Text === @buffer.first
733
- </span><span class="uncovered0"><a name="line133"></a>133 text = @buffer.shift
734
- </span><span class="uncovered1"><a name="line134"></a>134 @output_width = text.output(@output, @output_width)
735
- </span><span class="uncovered0"><a name="line135"></a>135 @buffer_width -= text.width
736
- </span><span class="uncovered1"><a name="line136"></a>136 end
737
- </span><span class="uncovered0"><a name="line137"></a>137 end
738
- </span><span class="uncovered1"><a name="line138"></a>138 end
739
- </span><span class="inferred0"><a name="line139"></a>139
740
- </span><span class="inferred1"><a name="line140"></a>140 # This adds +obj+ as a text of +width+ columns in width.
741
- </span><span class="inferred0"><a name="line141"></a>141 #
742
- </span><span class="inferred1"><a name="line142"></a>142 # If +width+ is not specified, obj.length is used.
743
- </span><span class="inferred0"><a name="line143"></a>143 #
744
- </span><span class="marked1"><a name="line144"></a>144 def text(obj, width=obj.length)
745
- </span><span class="uncovered0"><a name="line145"></a>145 if @buffer.empty?
746
- </span><span class="uncovered1"><a name="line146"></a>146 @output &lt;&lt; obj
747
- </span><span class="uncovered0"><a name="line147"></a>147 @output_width += width
748
- </span><span class="uncovered1"><a name="line148"></a>148 else
749
- </span><span class="uncovered0"><a name="line149"></a>149 text = @buffer.last
750
- </span><span class="uncovered1"><a name="line150"></a>150 unless Text === text
751
- </span><span class="uncovered0"><a name="line151"></a>151 text = Text.new
752
- </span><span class="uncovered1"><a name="line152"></a>152 @buffer &lt;&lt; text
753
- </span><span class="uncovered0"><a name="line153"></a>153 end
754
- </span><span class="uncovered1"><a name="line154"></a>154 text.add(obj, width)
755
- </span><span class="uncovered0"><a name="line155"></a>155 @buffer_width += width
756
- </span><span class="uncovered1"><a name="line156"></a>156 break_outmost_groups
757
- </span><span class="uncovered0"><a name="line157"></a>157 end
758
- </span><span class="uncovered1"><a name="line158"></a>158 end
759
- </span><span class="inferred0"><a name="line159"></a>159
760
- </span><span class="marked1"><a name="line160"></a>160 def fill_breakable(sep=' ', width=sep.length)
761
- </span><span class="uncovered0"><a name="line161"></a>161 group { breakable sep, width }
762
- </span><span class="uncovered1"><a name="line162"></a>162 end
763
- </span><span class="inferred0"><a name="line163"></a>163
764
- </span><span class="inferred1"><a name="line164"></a>164 # This tells &quot;you can break a line here if necessary&quot;, and a +width+\-column
765
- </span><span class="inferred0"><a name="line165"></a>165 # text +sep+ is inserted if a line is not broken at the point.
766
- </span><span class="inferred1"><a name="line166"></a>166 #
767
- </span><span class="inferred0"><a name="line167"></a>167 # If +sep+ is not specified, &quot; &quot; is used.
768
- </span><span class="inferred1"><a name="line168"></a>168 #
769
- </span><span class="inferred0"><a name="line169"></a>169 # If +width+ is not specified, +sep.length+ is used. You will have to
770
- </span><span class="inferred1"><a name="line170"></a>170 # specify this when +sep+ is a multibyte character, for example.
771
- </span><span class="inferred0"><a name="line171"></a>171 #
772
- </span><span class="marked1"><a name="line172"></a>172 def breakable(sep=' ', width=sep.length)
773
- </span><span class="uncovered0"><a name="line173"></a>173 group = @group_stack.last
774
- </span><span class="uncovered1"><a name="line174"></a>174 if group.break?
775
- </span><span class="uncovered0"><a name="line175"></a>175 flush
776
- </span><span class="uncovered1"><a name="line176"></a>176 @output &lt;&lt; @newline
777
- </span><span class="uncovered0"><a name="line177"></a>177 @output &lt;&lt; @genspace.call(@indent)
778
- </span><span class="uncovered1"><a name="line178"></a>178 @output_width = @indent
779
- </span><span class="uncovered0"><a name="line179"></a>179 @buffer_width = 0
780
- </span><span class="uncovered1"><a name="line180"></a>180 else
781
- </span><span class="uncovered0"><a name="line181"></a>181 @buffer &lt;&lt; Breakable.new(sep, width, self)
782
- </span><span class="uncovered1"><a name="line182"></a>182 @buffer_width += width
783
- </span><span class="uncovered0"><a name="line183"></a>183 break_outmost_groups
784
- </span><span class="uncovered1"><a name="line184"></a>184 end
785
- </span><span class="uncovered0"><a name="line185"></a>185 end
786
- </span><span class="inferred1"><a name="line186"></a>186
787
- </span><span class="inferred0"><a name="line187"></a>187 # Groups line break hints added in the block. The line break hints are all
788
- </span><span class="inferred1"><a name="line188"></a>188 # to be used or not.
789
- </span><span class="inferred0"><a name="line189"></a>189 #
790
- </span><span class="inferred1"><a name="line190"></a>190 # If +indent+ is specified, the method call is regarded as nested by
791
- </span><span class="inferred0"><a name="line191"></a>191 # nest(indent) { ... }.
792
- </span><span class="inferred1"><a name="line192"></a>192 #
793
- </span><span class="inferred0"><a name="line193"></a>193 # If +open_obj+ is specified, &lt;tt&gt;text open_obj, open_width&lt;/tt&gt; is called
794
- </span><span class="inferred1"><a name="line194"></a>194 # before grouping. If +close_obj+ is specified, &lt;tt&gt;text close_obj,
795
- </span><span class="inferred0"><a name="line195"></a>195 # close_width&lt;/tt&gt; is called after grouping.
796
- </span><span class="inferred1"><a name="line196"></a>196 #
797
- </span><span class="marked0"><a name="line197"></a>197 def group(indent=0, open_obj='', close_obj='', open_width=open_obj.length, close_width=close_obj.length)
798
- </span><span class="uncovered1"><a name="line198"></a>198 text open_obj, open_width
799
- </span><span class="uncovered0"><a name="line199"></a>199 group_sub {
800
- </span><span class="uncovered1"><a name="line200"></a>200 nest(indent) {
801
- </span><span class="uncovered0"><a name="line201"></a>201 yield
802
- </span><span class="uncovered1"><a name="line202"></a>202 }
803
- </span><span class="uncovered0"><a name="line203"></a>203 }
804
- </span><span class="uncovered1"><a name="line204"></a>204 text close_obj, close_width
805
- </span><span class="uncovered0"><a name="line205"></a>205 end
806
- </span><span class="inferred1"><a name="line206"></a>206
807
- </span><span class="marked0"><a name="line207"></a>207 def group_sub
808
- </span><span class="uncovered1"><a name="line208"></a>208 group = Group.new(@group_stack.last.depth + 1)
809
- </span><span class="uncovered0"><a name="line209"></a>209 @group_stack.push group
810
- </span><span class="uncovered1"><a name="line210"></a>210 @group_queue.enq group
811
- </span><span class="uncovered0"><a name="line211"></a>211 begin
812
- </span><span class="uncovered1"><a name="line212"></a>212 yield
813
- </span><span class="uncovered0"><a name="line213"></a>213 ensure
814
- </span><span class="uncovered1"><a name="line214"></a>214 @group_stack.pop
815
- </span><span class="uncovered0"><a name="line215"></a>215 if group.breakables.empty?
816
- </span><span class="uncovered1"><a name="line216"></a>216 @group_queue.delete group
817
- </span><span class="uncovered0"><a name="line217"></a>217 end
818
- </span><span class="uncovered1"><a name="line218"></a>218 end
819
- </span><span class="uncovered0"><a name="line219"></a>219 end
820
- </span><span class="inferred1"><a name="line220"></a>220
821
- </span><span class="inferred0"><a name="line221"></a>221 # Increases left margin after newline with +indent+ for line breaks added in
822
- </span><span class="inferred1"><a name="line222"></a>222 # the block.
823
- </span><span class="inferred0"><a name="line223"></a>223 #
824
- </span><span class="marked1"><a name="line224"></a>224 def nest(indent)
825
- </span><span class="uncovered0"><a name="line225"></a>225 @indent += indent
826
- </span><span class="uncovered1"><a name="line226"></a>226 begin
827
- </span><span class="uncovered0"><a name="line227"></a>227 yield
828
- </span><span class="uncovered1"><a name="line228"></a>228 ensure
829
- </span><span class="uncovered0"><a name="line229"></a>229 @indent -= indent
830
- </span><span class="uncovered1"><a name="line230"></a>230 end
831
- </span><span class="uncovered0"><a name="line231"></a>231 end
832
- </span><span class="inferred1"><a name="line232"></a>232
833
- </span><span class="inferred0"><a name="line233"></a>233 # outputs buffered data.
834
- </span><span class="inferred1"><a name="line234"></a>234 #
835
- </span><span class="marked0"><a name="line235"></a>235 def flush
836
- </span><span class="uncovered1"><a name="line236"></a>236 @buffer.each {|data|
837
- </span><span class="uncovered0"><a name="line237"></a>237 @output_width = data.output(@output, @output_width)
838
- </span><span class="uncovered1"><a name="line238"></a>238 }
839
- </span><span class="uncovered0"><a name="line239"></a>239 @buffer.clear
840
- </span><span class="uncovered1"><a name="line240"></a>240 @buffer_width = 0
841
- </span><span class="uncovered0"><a name="line241"></a>241 end
842
- </span><span class="inferred1"><a name="line242"></a>242
843
- </span><span class="marked0"><a name="line243"></a>243 class Text
844
- </span><span class="marked1"><a name="line244"></a>244 def initialize
845
- </span><span class="uncovered0"><a name="line245"></a>245 @objs = []
846
- </span><span class="uncovered1"><a name="line246"></a>246 @width = 0
847
- </span><span class="uncovered0"><a name="line247"></a>247 end
848
- </span><span class="marked1"><a name="line248"></a>248 attr_reader :width
849
- </span><span class="inferred0"><a name="line249"></a>249
850
- </span><span class="marked1"><a name="line250"></a>250 def output(out, output_width)
851
- </span><span class="uncovered0"><a name="line251"></a>251 @objs.each {|obj| out &lt;&lt; obj}
852
- </span><span class="uncovered1"><a name="line252"></a>252 output_width + @width
853
- </span><span class="uncovered0"><a name="line253"></a>253 end
854
- </span><span class="inferred1"><a name="line254"></a>254
855
- </span><span class="marked0"><a name="line255"></a>255 def add(obj, width)
856
- </span><span class="uncovered1"><a name="line256"></a>256 @objs &lt;&lt; obj
857
- </span><span class="uncovered0"><a name="line257"></a>257 @width += width
858
- </span><span class="uncovered1"><a name="line258"></a>258 end
859
- </span><span class="uncovered0"><a name="line259"></a>259 end
860
- </span><span class="inferred1"><a name="line260"></a>260
861
- </span><span class="marked0"><a name="line261"></a>261 class Breakable
862
- </span><span class="marked1"><a name="line262"></a>262 def initialize(sep, width, q)
863
- </span><span class="uncovered0"><a name="line263"></a>263 @obj = sep
864
- </span><span class="uncovered1"><a name="line264"></a>264 @width = width
865
- </span><span class="uncovered0"><a name="line265"></a>265 @pp = q
866
- </span><span class="uncovered1"><a name="line266"></a>266 @indent = q.indent
867
- </span><span class="uncovered0"><a name="line267"></a>267 @group = q.current_group
868
- </span><span class="uncovered1"><a name="line268"></a>268 @group.breakables.push self
869
- </span><span class="uncovered0"><a name="line269"></a>269 end
870
- </span><span class="marked1"><a name="line270"></a>270 attr_reader :obj, :width, :indent
871
- </span><span class="inferred0"><a name="line271"></a>271
872
- </span><span class="marked1"><a name="line272"></a>272 def output(out, output_width)
873
- </span><span class="uncovered0"><a name="line273"></a>273 @group.breakables.shift
874
- </span><span class="uncovered1"><a name="line274"></a>274 if @group.break?
875
- </span><span class="uncovered0"><a name="line275"></a>275 out &lt;&lt; @pp.newline
876
- </span><span class="uncovered1"><a name="line276"></a>276 out &lt;&lt; @pp.genspace.call(@indent)
877
- </span><span class="uncovered0"><a name="line277"></a>277 @indent
878
- </span><span class="uncovered1"><a name="line278"></a>278 else
879
- </span><span class="uncovered0"><a name="line279"></a>279 @pp.group_queue.delete @group if @group.breakables.empty?
880
- </span><span class="uncovered1"><a name="line280"></a>280 out &lt;&lt; @obj
881
- </span><span class="uncovered0"><a name="line281"></a>281 output_width + @width
882
- </span><span class="uncovered1"><a name="line282"></a>282 end
883
- </span><span class="uncovered0"><a name="line283"></a>283 end
884
- </span><span class="uncovered1"><a name="line284"></a>284 end
885
- </span><span class="inferred0"><a name="line285"></a>285
886
- </span><span class="marked1"><a name="line286"></a>286 class Group
887
- </span><span class="marked0"><a name="line287"></a>287 def initialize(depth)
888
- </span><span class="uncovered1"><a name="line288"></a>288 @depth = depth
889
- </span><span class="uncovered0"><a name="line289"></a>289 @breakables = []
890
- </span><span class="uncovered1"><a name="line290"></a>290 @break = false
891
- </span><span class="uncovered0"><a name="line291"></a>291 end
892
- </span><span class="marked1"><a name="line292"></a>292 attr_reader :depth, :breakables
893
- </span><span class="inferred0"><a name="line293"></a>293
894
- </span><span class="marked1"><a name="line294"></a>294 def break
895
- </span><span class="uncovered0"><a name="line295"></a>295 @break = true
896
- </span><span class="uncovered1"><a name="line296"></a>296 end
897
- </span><span class="inferred0"><a name="line297"></a>297
898
- </span><span class="marked1"><a name="line298"></a>298 def break?
899
- </span><span class="uncovered0"><a name="line299"></a>299 @break
900
- </span><span class="uncovered1"><a name="line300"></a>300 end
901
- </span><span class="inferred0"><a name="line301"></a>301
902
- </span><span class="marked1"><a name="line302"></a>302 def first?
903
- </span><span class="uncovered0"><a name="line303"></a>303 if defined? @first
904
- </span><span class="uncovered1"><a name="line304"></a>304 false
905
- </span><span class="uncovered0"><a name="line305"></a>305 else
906
- </span><span class="uncovered1"><a name="line306"></a>306 @first = false
907
- </span><span class="uncovered0"><a name="line307"></a>307 true
908
- </span><span class="uncovered1"><a name="line308"></a>308 end
909
- </span><span class="uncovered0"><a name="line309"></a>309 end
910
- </span><span class="uncovered1"><a name="line310"></a>310 end
911
- </span><span class="inferred0"><a name="line311"></a>311
912
- </span><span class="marked1"><a name="line312"></a>312 class GroupQueue
913
- </span><span class="marked0"><a name="line313"></a>313 def initialize(*groups)
914
- </span><span class="uncovered1"><a name="line314"></a>314 @queue = []
915
- </span><span class="uncovered0"><a name="line315"></a>315 groups.each {|g| enq g}
916
- </span><span class="uncovered1"><a name="line316"></a>316 end
917
- </span><span class="inferred0"><a name="line317"></a>317
918
- </span><span class="marked1"><a name="line318"></a>318 def enq(group)
919
- </span><span class="uncovered0"><a name="line319"></a>319 depth = group.depth
920
- </span><span class="uncovered1"><a name="line320"></a>320 @queue &lt;&lt; [] until depth &lt; @queue.length
921
- </span><span class="uncovered0"><a name="line321"></a>321 @queue[depth] &lt;&lt; group
922
- </span><span class="uncovered1"><a name="line322"></a>322 end
923
- </span><span class="inferred0"><a name="line323"></a>323
924
- </span><span class="marked1"><a name="line324"></a>324 def deq
925
- </span><span class="uncovered0"><a name="line325"></a>325 @queue.each {|gs|
926
- </span><span class="uncovered1"><a name="line326"></a>326 (gs.length-1).downto(0) {|i|
927
- </span><span class="uncovered0"><a name="line327"></a>327 unless gs[i].breakables.empty?
928
- </span><span class="uncovered1"><a name="line328"></a>328 group = gs.slice!(i, 1).first
929
- </span><span class="uncovered0"><a name="line329"></a>329 group.break
930
- </span><span class="uncovered1"><a name="line330"></a>330 return group
931
- </span><span class="uncovered0"><a name="line331"></a>331 end
932
- </span><span class="uncovered1"><a name="line332"></a>332 }
933
- </span><span class="uncovered0"><a name="line333"></a>333 gs.each {|group| group.break}
934
- </span><span class="uncovered1"><a name="line334"></a>334 gs.clear
935
- </span><span class="uncovered0"><a name="line335"></a>335 }
936
- </span><span class="uncovered1"><a name="line336"></a>336 return nil
937
- </span><span class="uncovered0"><a name="line337"></a>337 end
938
- </span><span class="inferred1"><a name="line338"></a>338
939
- </span><span class="marked0"><a name="line339"></a>339 def delete(group)
940
- </span><span class="uncovered1"><a name="line340"></a>340 @queue[group.depth].delete(group)
941
- </span><span class="uncovered0"><a name="line341"></a>341 end
942
- </span><span class="uncovered1"><a name="line342"></a>342 end
943
- </span><span class="inferred0"><a name="line343"></a>343
944
- </span><span class="marked1"><a name="line344"></a>344 class SingleLine
945
- </span><span class="marked0"><a name="line345"></a>345 def initialize(output, maxwidth=nil, newline=nil)
946
- </span><span class="uncovered1"><a name="line346"></a>346 @output = output
947
- </span><span class="uncovered0"><a name="line347"></a>347 @first = [true]
948
- </span><span class="uncovered1"><a name="line348"></a>348 end
949
- </span><span class="inferred0"><a name="line349"></a>349
950
- </span><span class="marked1"><a name="line350"></a>350 def text(obj, width=nil)
951
- </span><span class="uncovered0"><a name="line351"></a>351 @output &lt;&lt; obj
952
- </span><span class="uncovered1"><a name="line352"></a>352 end
953
- </span><span class="inferred0"><a name="line353"></a>353
954
- </span><span class="marked1"><a name="line354"></a>354 def breakable(sep=' ', width=nil)
955
- </span><span class="uncovered0"><a name="line355"></a>355 @output &lt;&lt; sep
956
- </span><span class="uncovered1"><a name="line356"></a>356 end
957
- </span><span class="inferred0"><a name="line357"></a>357
958
- </span><span class="marked1"><a name="line358"></a>358 def nest(indent)
959
- </span><span class="uncovered0"><a name="line359"></a>359 yield
960
- </span><span class="uncovered1"><a name="line360"></a>360 end
961
- </span><span class="inferred0"><a name="line361"></a>361
962
- </span><span class="marked1"><a name="line362"></a>362 def group(indent=nil, open_obj='', close_obj='', open_width=nil, close_width=nil)
963
- </span><span class="uncovered0"><a name="line363"></a>363 @first.push true
964
- </span><span class="uncovered1"><a name="line364"></a>364 @output &lt;&lt; open_obj
965
- </span><span class="uncovered0"><a name="line365"></a>365 yield
966
- </span><span class="uncovered1"><a name="line366"></a>366 @output &lt;&lt; close_obj
967
- </span><span class="uncovered0"><a name="line367"></a>367 @first.pop
968
- </span><span class="uncovered1"><a name="line368"></a>368 end
969
- </span><span class="inferred0"><a name="line369"></a>369
970
- </span><span class="marked1"><a name="line370"></a>370 def flush
971
- </span><span class="inferred0"><a name="line371"></a>371 end
972
- </span><span class="inferred1"><a name="line372"></a>372
973
- </span><span class="marked0"><a name="line373"></a>373 def first?
974
- </span><span class="uncovered1"><a name="line374"></a>374 result = @first[-1]
975
- </span><span class="uncovered0"><a name="line375"></a>375 @first[-1] = false
976
- </span><span class="uncovered1"><a name="line376"></a>376 result
977
- </span><span class="uncovered0"><a name="line377"></a>377 end
978
- </span><span class="uncovered1"><a name="line378"></a>378 end
979
- </span><span class="uncovered0"><a name="line379"></a>379 end
980
- </span><span class="inferred1"><a name="line380"></a>380
981
- </span><span class="marked0"><a name="line381"></a>381 if __FILE__ == $0
982
- </span><span class="uncovered1"><a name="line382"></a>382 require 'test/unit'
983
- </span><span class="uncovered0"><a name="line383"></a>383
984
- </span><span class="uncovered1"><a name="line384"></a>384 class WadlerExample &lt; Test::Unit::TestCase # :nodoc:
985
- </span><span class="uncovered0"><a name="line385"></a>385 def setup
986
- </span><span class="uncovered1"><a name="line386"></a>386 @tree = Tree.new(&quot;aaaa&quot;, Tree.new(&quot;bbbbb&quot;, Tree.new(&quot;ccc&quot;),
987
- </span><span class="uncovered0"><a name="line387"></a>387 Tree.new(&quot;dd&quot;)),
988
- </span><span class="uncovered1"><a name="line388"></a>388 Tree.new(&quot;eee&quot;),
989
- </span><span class="uncovered0"><a name="line389"></a>389 Tree.new(&quot;ffff&quot;, Tree.new(&quot;gg&quot;),
990
- </span><span class="uncovered1"><a name="line390"></a>390 Tree.new(&quot;hhh&quot;),
991
- </span><span class="uncovered0"><a name="line391"></a>391 Tree.new(&quot;ii&quot;)))
992
- </span><span class="uncovered1"><a name="line392"></a>392 end
993
- </span><span class="uncovered0"><a name="line393"></a>393
994
- </span><span class="uncovered1"><a name="line394"></a>394 def hello(width)
995
- </span><span class="uncovered0"><a name="line395"></a>395 PrettyPrint.format('', width) {|hello|
996
- </span><span class="uncovered1"><a name="line396"></a>396 hello.group {
997
- </span><span class="uncovered0"><a name="line397"></a>397 hello.group {
998
- </span><span class="uncovered1"><a name="line398"></a>398 hello.group {
999
- </span><span class="uncovered0"><a name="line399"></a>399 hello.group {
1000
- </span><span class="uncovered1"><a name="line400"></a>400 hello.text 'hello'
1001
- </span><span class="uncovered0"><a name="line401"></a>401 hello.breakable; hello.text 'a'
1002
- </span><span class="uncovered1"><a name="line402"></a>402 }
1003
- </span><span class="uncovered0"><a name="line403"></a>403 hello.breakable; hello.text 'b'
1004
- </span><span class="uncovered1"><a name="line404"></a>404 }
1005
- </span><span class="uncovered0"><a name="line405"></a>405 hello.breakable; hello.text 'c'
1006
- </span><span class="uncovered1"><a name="line406"></a>406 }
1007
- </span><span class="uncovered0"><a name="line407"></a>407 hello.breakable; hello.text 'd'
1008
- </span><span class="uncovered1"><a name="line408"></a>408 }
1009
- </span><span class="uncovered0"><a name="line409"></a>409 }
1010
- </span><span class="uncovered1"><a name="line410"></a>410 end
1011
- </span><span class="uncovered0"><a name="line411"></a>411
1012
- </span><span class="uncovered1"><a name="line412"></a>412 def test_hello_00_06
1013
- </span><span class="uncovered0"><a name="line413"></a>413 expected = &lt;&lt;'End'.chomp
1014
- </span><span class="uncovered1"><a name="line414"></a>414 hello
1015
- </span><span class="uncovered0"><a name="line415"></a>415 a
1016
- </span><span class="uncovered1"><a name="line416"></a>416 b
1017
- </span><span class="uncovered0"><a name="line417"></a>417 c
1018
- </span><span class="uncovered1"><a name="line418"></a>418 d
1019
- </span><span class="uncovered0"><a name="line419"></a>419 End
1020
- </span><span class="uncovered1"><a name="line420"></a>420 assert_equal(expected, hello(0))
1021
- </span><span class="uncovered0"><a name="line421"></a>421 assert_equal(expected, hello(6))
1022
- </span><span class="uncovered1"><a name="line422"></a>422 end
1023
- </span><span class="uncovered0"><a name="line423"></a>423
1024
- </span><span class="uncovered1"><a name="line424"></a>424 def test_hello_07_08
1025
- </span><span class="uncovered0"><a name="line425"></a>425 expected = &lt;&lt;'End'.chomp
1026
- </span><span class="uncovered1"><a name="line426"></a>426 hello a
1027
- </span><span class="uncovered0"><a name="line427"></a>427 b
1028
- </span><span class="uncovered1"><a name="line428"></a>428 c
1029
- </span><span class="uncovered0"><a name="line429"></a>429 d
1030
- </span><span class="uncovered1"><a name="line430"></a>430 End
1031
- </span><span class="uncovered0"><a name="line431"></a>431 assert_equal(expected, hello(7))
1032
- </span><span class="uncovered1"><a name="line432"></a>432 assert_equal(expected, hello(8))
1033
- </span><span class="uncovered0"><a name="line433"></a>433 end
1034
- </span><span class="uncovered1"><a name="line434"></a>434
1035
- </span><span class="uncovered0"><a name="line435"></a>435 def test_hello_09_10
1036
- </span><span class="uncovered1"><a name="line436"></a>436 expected = &lt;&lt;'End'.chomp
1037
- </span><span class="uncovered0"><a name="line437"></a>437 hello a b
1038
- </span><span class="uncovered1"><a name="line438"></a>438 c
1039
- </span><span class="uncovered0"><a name="line439"></a>439 d
1040
- </span><span class="uncovered1"><a name="line440"></a>440 End
1041
- </span><span class="uncovered0"><a name="line441"></a>441 out = hello(9); assert_equal(expected, out)
1042
- </span><span class="uncovered1"><a name="line442"></a>442 out = hello(10); assert_equal(expected, out)
1043
- </span><span class="uncovered0"><a name="line443"></a>443 end
1044
- </span><span class="uncovered1"><a name="line444"></a>444
1045
- </span><span class="uncovered0"><a name="line445"></a>445 def test_hello_11_12
1046
- </span><span class="uncovered1"><a name="line446"></a>446 expected = &lt;&lt;'End'.chomp
1047
- </span><span class="uncovered0"><a name="line447"></a>447 hello a b c
1048
- </span><span class="uncovered1"><a name="line448"></a>448 d
1049
- </span><span class="uncovered0"><a name="line449"></a>449 End
1050
- </span><span class="uncovered1"><a name="line450"></a>450 assert_equal(expected, hello(11))
1051
- </span><span class="uncovered0"><a name="line451"></a>451 assert_equal(expected, hello(12))
1052
- </span><span class="uncovered1"><a name="line452"></a>452 end
1053
- </span><span class="uncovered0"><a name="line453"></a>453
1054
- </span><span class="uncovered1"><a name="line454"></a>454 def test_hello_13
1055
- </span><span class="uncovered0"><a name="line455"></a>455 expected = &lt;&lt;'End'.chomp
1056
- </span><span class="uncovered1"><a name="line456"></a>456 hello a b c d
1057
- </span><span class="uncovered0"><a name="line457"></a>457 End
1058
- </span><span class="uncovered1"><a name="line458"></a>458 assert_equal(expected, hello(13))
1059
- </span><span class="uncovered0"><a name="line459"></a>459 end
1060
- </span><span class="uncovered1"><a name="line460"></a>460
1061
- </span><span class="uncovered0"><a name="line461"></a>461 def tree(width)
1062
- </span><span class="uncovered1"><a name="line462"></a>462 PrettyPrint.format('', width) {|q| @tree.show(q)}
1063
- </span><span class="uncovered0"><a name="line463"></a>463 end
1064
- </span><span class="uncovered1"><a name="line464"></a>464
1065
- </span><span class="uncovered0"><a name="line465"></a>465 def test_tree_00_19
1066
- </span><span class="uncovered1"><a name="line466"></a>466 expected = &lt;&lt;'End'.chomp
1067
- </span><span class="uncovered0"><a name="line467"></a>467 aaaa[bbbbb[ccc,
1068
- </span><span class="uncovered1"><a name="line468"></a>468 dd],
1069
- </span><span class="uncovered0"><a name="line469"></a>469 eee,
1070
- </span><span class="uncovered1"><a name="line470"></a>470 ffff[gg,
1071
- </span><span class="uncovered0"><a name="line471"></a>471 hhh,
1072
- </span><span class="uncovered1"><a name="line472"></a>472 ii]]
1073
- </span><span class="uncovered0"><a name="line473"></a>473 End
1074
- </span><span class="uncovered1"><a name="line474"></a>474 assert_equal(expected, tree(0))
1075
- </span><span class="uncovered0"><a name="line475"></a>475 assert_equal(expected, tree(19))
1076
- </span><span class="uncovered1"><a name="line476"></a>476 end
1077
- </span><span class="uncovered0"><a name="line477"></a>477
1078
- </span><span class="uncovered1"><a name="line478"></a>478 def test_tree_20_22
1079
- </span><span class="uncovered0"><a name="line479"></a>479 expected = &lt;&lt;'End'.chomp
1080
- </span><span class="uncovered1"><a name="line480"></a>480 aaaa[bbbbb[ccc, dd],
1081
- </span><span class="uncovered0"><a name="line481"></a>481 eee,
1082
- </span><span class="uncovered1"><a name="line482"></a>482 ffff[gg,
1083
- </span><span class="uncovered0"><a name="line483"></a>483 hhh,
1084
- </span><span class="uncovered1"><a name="line484"></a>484 ii]]
1085
- </span><span class="uncovered0"><a name="line485"></a>485 End
1086
- </span><span class="uncovered1"><a name="line486"></a>486 assert_equal(expected, tree(20))
1087
- </span><span class="uncovered0"><a name="line487"></a>487 assert_equal(expected, tree(22))
1088
- </span><span class="uncovered1"><a name="line488"></a>488 end
1089
- </span><span class="uncovered0"><a name="line489"></a>489
1090
- </span><span class="uncovered1"><a name="line490"></a>490 def test_tree_23_43
1091
- </span><span class="uncovered0"><a name="line491"></a>491 expected = &lt;&lt;'End'.chomp
1092
- </span><span class="uncovered1"><a name="line492"></a>492 aaaa[bbbbb[ccc, dd],
1093
- </span><span class="uncovered0"><a name="line493"></a>493 eee,
1094
- </span><span class="uncovered1"><a name="line494"></a>494 ffff[gg, hhh, ii]]
1095
- </span><span class="uncovered0"><a name="line495"></a>495 End
1096
- </span><span class="uncovered1"><a name="line496"></a>496 assert_equal(expected, tree(23))
1097
- </span><span class="uncovered0"><a name="line497"></a>497 assert_equal(expected, tree(43))
1098
- </span><span class="uncovered1"><a name="line498"></a>498 end
1099
- </span><span class="uncovered0"><a name="line499"></a>499
1100
- </span><span class="uncovered1"><a name="line500"></a>500 def test_tree_44
1101
- </span><span class="uncovered0"><a name="line501"></a>501 assert_equal(&lt;&lt;'End'.chomp, tree(44))
1102
- </span><span class="uncovered1"><a name="line502"></a>502 aaaa[bbbbb[ccc, dd], eee, ffff[gg, hhh, ii]]
1103
- </span><span class="uncovered0"><a name="line503"></a>503 End
1104
- </span><span class="uncovered1"><a name="line504"></a>504 end
1105
- </span><span class="uncovered0"><a name="line505"></a>505
1106
- </span><span class="uncovered1"><a name="line506"></a>506 def tree_alt(width)
1107
- </span><span class="uncovered0"><a name="line507"></a>507 PrettyPrint.format('', width) {|q| @tree.altshow(q)}
1108
- </span><span class="uncovered1"><a name="line508"></a>508 end
1109
- </span><span class="uncovered0"><a name="line509"></a>509
1110
- </span><span class="uncovered1"><a name="line510"></a>510 def test_tree_alt_00_18
1111
- </span><span class="uncovered0"><a name="line511"></a>511 expected = &lt;&lt;'End'.chomp
1112
- </span><span class="uncovered1"><a name="line512"></a>512 aaaa[
1113
- </span><span class="uncovered0"><a name="line513"></a>513 bbbbb[
1114
- </span><span class="uncovered1"><a name="line514"></a>514 ccc,
1115
- </span><span class="uncovered0"><a name="line515"></a>515 dd
1116
- </span><span class="uncovered1"><a name="line516"></a>516 ],
1117
- </span><span class="uncovered0"><a name="line517"></a>517 eee,
1118
- </span><span class="uncovered1"><a name="line518"></a>518 ffff[
1119
- </span><span class="uncovered0"><a name="line519"></a>519 gg,
1120
- </span><span class="uncovered1"><a name="line520"></a>520 hhh,
1121
- </span><span class="uncovered0"><a name="line521"></a>521 ii
1122
- </span><span class="uncovered1"><a name="line522"></a>522 ]
1123
- </span><span class="uncovered0"><a name="line523"></a>523 ]
1124
- </span><span class="uncovered1"><a name="line524"></a>524 End
1125
- </span><span class="uncovered0"><a name="line525"></a>525 assert_equal(expected, tree_alt(0))
1126
- </span><span class="uncovered1"><a name="line526"></a>526 assert_equal(expected, tree_alt(18))
1127
- </span><span class="uncovered0"><a name="line527"></a>527 end
1128
- </span><span class="uncovered1"><a name="line528"></a>528
1129
- </span><span class="uncovered0"><a name="line529"></a>529 def test_tree_alt_19_20
1130
- </span><span class="uncovered1"><a name="line530"></a>530 expected = &lt;&lt;'End'.chomp
1131
- </span><span class="uncovered0"><a name="line531"></a>531 aaaa[
1132
- </span><span class="uncovered1"><a name="line532"></a>532 bbbbb[ ccc, dd ],
1133
- </span><span class="uncovered0"><a name="line533"></a>533 eee,
1134
- </span><span class="uncovered1"><a name="line534"></a>534 ffff[
1135
- </span><span class="uncovered0"><a name="line535"></a>535 gg,
1136
- </span><span class="uncovered1"><a name="line536"></a>536 hhh,
1137
- </span><span class="uncovered0"><a name="line537"></a>537 ii
1138
- </span><span class="uncovered1"><a name="line538"></a>538 ]
1139
- </span><span class="uncovered0"><a name="line539"></a>539 ]
1140
- </span><span class="uncovered1"><a name="line540"></a>540 End
1141
- </span><span class="uncovered0"><a name="line541"></a>541 assert_equal(expected, tree_alt(19))
1142
- </span><span class="uncovered1"><a name="line542"></a>542 assert_equal(expected, tree_alt(20))
1143
- </span><span class="uncovered0"><a name="line543"></a>543 end
1144
- </span><span class="uncovered1"><a name="line544"></a>544
1145
- </span><span class="uncovered0"><a name="line545"></a>545 def test_tree_alt_20_49
1146
- </span><span class="uncovered1"><a name="line546"></a>546 expected = &lt;&lt;'End'.chomp
1147
- </span><span class="uncovered0"><a name="line547"></a>547 aaaa[
1148
- </span><span class="uncovered1"><a name="line548"></a>548 bbbbb[ ccc, dd ],
1149
- </span><span class="uncovered0"><a name="line549"></a>549 eee,
1150
- </span><span class="uncovered1"><a name="line550"></a>550 ffff[ gg, hhh, ii ]
1151
- </span><span class="uncovered0"><a name="line551"></a>551 ]
1152
- </span><span class="uncovered1"><a name="line552"></a>552 End
1153
- </span><span class="uncovered0"><a name="line553"></a>553 assert_equal(expected, tree_alt(21))
1154
- </span><span class="uncovered1"><a name="line554"></a>554 assert_equal(expected, tree_alt(49))
1155
- </span><span class="uncovered0"><a name="line555"></a>555 end
1156
- </span><span class="uncovered1"><a name="line556"></a>556
1157
- </span><span class="uncovered0"><a name="line557"></a>557 def test_tree_alt_50
1158
- </span><span class="uncovered1"><a name="line558"></a>558 expected = &lt;&lt;'End'.chomp
1159
- </span><span class="uncovered0"><a name="line559"></a>559 aaaa[ bbbbb[ ccc, dd ], eee, ffff[ gg, hhh, ii ] ]
1160
- </span><span class="uncovered1"><a name="line560"></a>560 End
1161
- </span><span class="uncovered0"><a name="line561"></a>561 assert_equal(expected, tree_alt(50))
1162
- </span><span class="uncovered1"><a name="line562"></a>562 end
1163
- </span><span class="uncovered0"><a name="line563"></a>563
1164
- </span><span class="uncovered1"><a name="line564"></a>564 class Tree # :nodoc:
1165
- </span><span class="uncovered0"><a name="line565"></a>565 def initialize(string, *children)
1166
- </span><span class="uncovered1"><a name="line566"></a>566 @string = string
1167
- </span><span class="uncovered0"><a name="line567"></a>567 @children = children
1168
- </span><span class="uncovered1"><a name="line568"></a>568 end
1169
- </span><span class="uncovered0"><a name="line569"></a>569
1170
- </span><span class="uncovered1"><a name="line570"></a>570 def show(q)
1171
- </span><span class="uncovered0"><a name="line571"></a>571 q.group {
1172
- </span><span class="uncovered1"><a name="line572"></a>572 q.text @string
1173
- </span><span class="uncovered0"><a name="line573"></a>573 q.nest(@string.length) {
1174
- </span><span class="uncovered1"><a name="line574"></a>574 unless @children.empty?
1175
- </span><span class="uncovered0"><a name="line575"></a>575 q.text '['
1176
- </span><span class="uncovered1"><a name="line576"></a>576 q.nest(1) {
1177
- </span><span class="uncovered0"><a name="line577"></a>577 first = true
1178
- </span><span class="uncovered1"><a name="line578"></a>578 @children.each {|t|
1179
- </span><span class="uncovered0"><a name="line579"></a>579 if first
1180
- </span><span class="uncovered1"><a name="line580"></a>580 first = false
1181
- </span><span class="uncovered0"><a name="line581"></a>581 else
1182
- </span><span class="uncovered1"><a name="line582"></a>582 q.text ','
1183
- </span><span class="uncovered0"><a name="line583"></a>583 q.breakable
1184
- </span><span class="uncovered1"><a name="line584"></a>584 end
1185
- </span><span class="uncovered0"><a name="line585"></a>585 t.show(q)
1186
- </span><span class="uncovered1"><a name="line586"></a>586 }
1187
- </span><span class="uncovered0"><a name="line587"></a>587 }
1188
- </span><span class="uncovered1"><a name="line588"></a>588 q.text ']'
1189
- </span><span class="uncovered0"><a name="line589"></a>589 end
1190
- </span><span class="uncovered1"><a name="line590"></a>590 }
1191
- </span><span class="uncovered0"><a name="line591"></a>591 }
1192
- </span><span class="uncovered1"><a name="line592"></a>592 end
1193
- </span><span class="uncovered0"><a name="line593"></a>593
1194
- </span><span class="uncovered1"><a name="line594"></a>594 def altshow(q)
1195
- </span><span class="uncovered0"><a name="line595"></a>595 q.group {
1196
- </span><span class="uncovered1"><a name="line596"></a>596 q.text @string
1197
- </span><span class="uncovered0"><a name="line597"></a>597 unless @children.empty?
1198
- </span><span class="uncovered1"><a name="line598"></a>598 q.text '['
1199
- </span><span class="uncovered0"><a name="line599"></a>599 q.nest(2) {
1200
- </span><span class="uncovered1"><a name="line600"></a>600 q.breakable
1201
- </span><span class="uncovered0"><a name="line601"></a>601 first = true
1202
- </span><span class="uncovered1"><a name="line602"></a>602 @children.each {|t|
1203
- </span><span class="uncovered0"><a name="line603"></a>603 if first
1204
- </span><span class="uncovered1"><a name="line604"></a>604 first = false
1205
- </span><span class="uncovered0"><a name="line605"></a>605 else
1206
- </span><span class="uncovered1"><a name="line606"></a>606 q.text ','
1207
- </span><span class="uncovered0"><a name="line607"></a>607 q.breakable
1208
- </span><span class="uncovered1"><a name="line608"></a>608 end
1209
- </span><span class="uncovered0"><a name="line609"></a>609 t.altshow(q)
1210
- </span><span class="uncovered1"><a name="line610"></a>610 }
1211
- </span><span class="uncovered0"><a name="line611"></a>611 }
1212
- </span><span class="uncovered1"><a name="line612"></a>612 q.breakable
1213
- </span><span class="uncovered0"><a name="line613"></a>613 q.text ']'
1214
- </span><span class="uncovered1"><a name="line614"></a>614 end
1215
- </span><span class="uncovered0"><a name="line615"></a>615 }
1216
- </span><span class="uncovered1"><a name="line616"></a>616 end
1217
- </span><span class="uncovered0"><a name="line617"></a>617
1218
- </span><span class="uncovered1"><a name="line618"></a>618 end
1219
- </span><span class="uncovered0"><a name="line619"></a>619 end
1220
- </span><span class="uncovered1"><a name="line620"></a>620
1221
- </span><span class="uncovered0"><a name="line621"></a>621 class StrictPrettyExample &lt; Test::Unit::TestCase # :nodoc:
1222
- </span><span class="uncovered1"><a name="line622"></a>622 def prog(width)
1223
- </span><span class="uncovered0"><a name="line623"></a>623 PrettyPrint.format('', width) {|q|
1224
- </span><span class="uncovered1"><a name="line624"></a>624 q.group {
1225
- </span><span class="uncovered0"><a name="line625"></a>625 q.group {q.nest(2) {
1226
- </span><span class="uncovered1"><a name="line626"></a>626 q.text &quot;if&quot;; q.breakable;
1227
- </span><span class="uncovered0"><a name="line627"></a>627 q.group {
1228
- </span><span class="uncovered1"><a name="line628"></a>628 q.nest(2) {
1229
- </span><span class="uncovered0"><a name="line629"></a>629 q.group {q.text &quot;a&quot;; q.breakable; q.text &quot;==&quot;}
1230
- </span><span class="uncovered1"><a name="line630"></a>630 q.breakable; q.text &quot;b&quot;}}}}
1231
- </span><span class="uncovered0"><a name="line631"></a>631 q.breakable
1232
- </span><span class="uncovered1"><a name="line632"></a>632 q.group {q.nest(2) {
1233
- </span><span class="uncovered0"><a name="line633"></a>633 q.text &quot;then&quot;; q.breakable;
1234
- </span><span class="uncovered1"><a name="line634"></a>634 q.group {
1235
- </span><span class="uncovered0"><a name="line635"></a>635 q.nest(2) {
1236
- </span><span class="uncovered1"><a name="line636"></a>636 q.group {q.text &quot;a&quot;; q.breakable; q.text &quot;&lt;&lt;&quot;}
1237
- </span><span class="uncovered0"><a name="line637"></a>637 q.breakable; q.text &quot;2&quot;}}}}
1238
- </span><span class="uncovered1"><a name="line638"></a>638 q.breakable
1239
- </span><span class="uncovered0"><a name="line639"></a>639 q.group {q.nest(2) {
1240
- </span><span class="uncovered1"><a name="line640"></a>640 q.text &quot;else&quot;; q.breakable;
1241
- </span><span class="uncovered0"><a name="line641"></a>641 q.group {
1242
- </span><span class="uncovered1"><a name="line642"></a>642 q.nest(2) {
1243
- </span><span class="uncovered0"><a name="line643"></a>643 q.group {q.text &quot;a&quot;; q.breakable; q.text &quot;+&quot;}
1244
- </span><span class="uncovered1"><a name="line644"></a>644 q.breakable; q.text &quot;b&quot;}}}}}
1245
- </span><span class="uncovered0"><a name="line645"></a>645 }
1246
- </span><span class="uncovered1"><a name="line646"></a>646 end
1247
- </span><span class="uncovered0"><a name="line647"></a>647
1248
- </span><span class="uncovered1"><a name="line648"></a>648 def test_00_04
1249
- </span><span class="uncovered0"><a name="line649"></a>649 expected = &lt;&lt;'End'.chomp
1250
- </span><span class="uncovered1"><a name="line650"></a>650 if
1251
- </span><span class="uncovered0"><a name="line651"></a>651 a
1252
- </span><span class="uncovered1"><a name="line652"></a>652 ==
1253
- </span><span class="uncovered0"><a name="line653"></a>653 b
1254
- </span><span class="uncovered1"><a name="line654"></a>654 then
1255
- </span><span class="uncovered0"><a name="line655"></a>655 a
1256
- </span><span class="uncovered1"><a name="line656"></a>656 &lt;&lt;
1257
- </span><span class="uncovered0"><a name="line657"></a>657 2
1258
- </span><span class="uncovered1"><a name="line658"></a>658 else
1259
- </span><span class="uncovered0"><a name="line659"></a>659 a
1260
- </span><span class="uncovered1"><a name="line660"></a>660 +
1261
- </span><span class="uncovered0"><a name="line661"></a>661 b
1262
- </span><span class="uncovered1"><a name="line662"></a>662 End
1263
- </span><span class="uncovered0"><a name="line663"></a>663 assert_equal(expected, prog(0))
1264
- </span><span class="uncovered1"><a name="line664"></a>664 assert_equal(expected, prog(4))
1265
- </span><span class="uncovered0"><a name="line665"></a>665 end
1266
- </span><span class="uncovered1"><a name="line666"></a>666
1267
- </span><span class="uncovered0"><a name="line667"></a>667 def test_05
1268
- </span><span class="uncovered1"><a name="line668"></a>668 expected = &lt;&lt;'End'.chomp
1269
- </span><span class="uncovered0"><a name="line669"></a>669 if
1270
- </span><span class="uncovered1"><a name="line670"></a>670 a
1271
- </span><span class="uncovered0"><a name="line671"></a>671 ==
1272
- </span><span class="uncovered1"><a name="line672"></a>672 b
1273
- </span><span class="uncovered0"><a name="line673"></a>673 then
1274
- </span><span class="uncovered1"><a name="line674"></a>674 a
1275
- </span><span class="uncovered0"><a name="line675"></a>675 &lt;&lt;
1276
- </span><span class="uncovered1"><a name="line676"></a>676 2
1277
- </span><span class="uncovered0"><a name="line677"></a>677 else
1278
- </span><span class="uncovered1"><a name="line678"></a>678 a +
1279
- </span><span class="uncovered0"><a name="line679"></a>679 b
1280
- </span><span class="uncovered1"><a name="line680"></a>680 End
1281
- </span><span class="uncovered0"><a name="line681"></a>681 assert_equal(expected, prog(5))
1282
- </span><span class="uncovered1"><a name="line682"></a>682 end
1283
- </span><span class="uncovered0"><a name="line683"></a>683
1284
- </span><span class="uncovered1"><a name="line684"></a>684 def test_06
1285
- </span><span class="uncovered0"><a name="line685"></a>685 expected = &lt;&lt;'End'.chomp
1286
- </span><span class="uncovered1"><a name="line686"></a>686 if
1287
- </span><span class="uncovered0"><a name="line687"></a>687 a ==
1288
- </span><span class="uncovered1"><a name="line688"></a>688 b
1289
- </span><span class="uncovered0"><a name="line689"></a>689 then
1290
- </span><span class="uncovered1"><a name="line690"></a>690 a &lt;&lt;
1291
- </span><span class="uncovered0"><a name="line691"></a>691 2
1292
- </span><span class="uncovered1"><a name="line692"></a>692 else
1293
- </span><span class="uncovered0"><a name="line693"></a>693 a +
1294
- </span><span class="uncovered1"><a name="line694"></a>694 b
1295
- </span><span class="uncovered0"><a name="line695"></a>695 End
1296
- </span><span class="uncovered1"><a name="line696"></a>696 assert_equal(expected, prog(6))
1297
- </span><span class="uncovered0"><a name="line697"></a>697 end
1298
- </span><span class="uncovered1"><a name="line698"></a>698
1299
- </span><span class="uncovered0"><a name="line699"></a>699 def test_07
1300
- </span><span class="uncovered1"><a name="line700"></a>700 expected = &lt;&lt;'End'.chomp
1301
- </span><span class="uncovered0"><a name="line701"></a>701 if
1302
- </span><span class="uncovered1"><a name="line702"></a>702 a ==
1303
- </span><span class="uncovered0"><a name="line703"></a>703 b
1304
- </span><span class="uncovered1"><a name="line704"></a>704 then
1305
- </span><span class="uncovered0"><a name="line705"></a>705 a &lt;&lt;
1306
- </span><span class="uncovered1"><a name="line706"></a>706 2
1307
- </span><span class="uncovered0"><a name="line707"></a>707 else
1308
- </span><span class="uncovered1"><a name="line708"></a>708 a + b
1309
- </span><span class="uncovered0"><a name="line709"></a>709 End
1310
- </span><span class="uncovered1"><a name="line710"></a>710 assert_equal(expected, prog(7))
1311
- </span><span class="uncovered0"><a name="line711"></a>711 end
1312
- </span><span class="uncovered1"><a name="line712"></a>712
1313
- </span><span class="uncovered0"><a name="line713"></a>713 def test_08
1314
- </span><span class="uncovered1"><a name="line714"></a>714 expected = &lt;&lt;'End'.chomp
1315
- </span><span class="uncovered0"><a name="line715"></a>715 if
1316
- </span><span class="uncovered1"><a name="line716"></a>716 a == b
1317
- </span><span class="uncovered0"><a name="line717"></a>717 then
1318
- </span><span class="uncovered1"><a name="line718"></a>718 a &lt;&lt; 2
1319
- </span><span class="uncovered0"><a name="line719"></a>719 else
1320
- </span><span class="uncovered1"><a name="line720"></a>720 a + b
1321
- </span><span class="uncovered0"><a name="line721"></a>721 End
1322
- </span><span class="uncovered1"><a name="line722"></a>722 assert_equal(expected, prog(8))
1323
- </span><span class="uncovered0"><a name="line723"></a>723 end
1324
- </span><span class="uncovered1"><a name="line724"></a>724
1325
- </span><span class="uncovered0"><a name="line725"></a>725 def test_09
1326
- </span><span class="uncovered1"><a name="line726"></a>726 expected = &lt;&lt;'End'.chomp
1327
- </span><span class="uncovered0"><a name="line727"></a>727 if a == b
1328
- </span><span class="uncovered1"><a name="line728"></a>728 then
1329
- </span><span class="uncovered0"><a name="line729"></a>729 a &lt;&lt; 2
1330
- </span><span class="uncovered1"><a name="line730"></a>730 else
1331
- </span><span class="uncovered0"><a name="line731"></a>731 a + b
1332
- </span><span class="uncovered1"><a name="line732"></a>732 End
1333
- </span><span class="uncovered0"><a name="line733"></a>733 assert_equal(expected, prog(9))
1334
- </span><span class="uncovered1"><a name="line734"></a>734 end
1335
- </span><span class="uncovered0"><a name="line735"></a>735
1336
- </span><span class="uncovered1"><a name="line736"></a>736 def test_10
1337
- </span><span class="uncovered0"><a name="line737"></a>737 expected = &lt;&lt;'End'.chomp
1338
- </span><span class="uncovered1"><a name="line738"></a>738 if a == b
1339
- </span><span class="uncovered0"><a name="line739"></a>739 then
1340
- </span><span class="uncovered1"><a name="line740"></a>740 a &lt;&lt; 2
1341
- </span><span class="uncovered0"><a name="line741"></a>741 else a + b
1342
- </span><span class="uncovered1"><a name="line742"></a>742 End
1343
- </span><span class="uncovered0"><a name="line743"></a>743 assert_equal(expected, prog(10))
1344
- </span><span class="uncovered1"><a name="line744"></a>744 end
1345
- </span><span class="uncovered0"><a name="line745"></a>745
1346
- </span><span class="uncovered1"><a name="line746"></a>746 def test_11_31
1347
- </span><span class="uncovered0"><a name="line747"></a>747 expected = &lt;&lt;'End'.chomp
1348
- </span><span class="uncovered1"><a name="line748"></a>748 if a == b
1349
- </span><span class="uncovered0"><a name="line749"></a>749 then a &lt;&lt; 2
1350
- </span><span class="uncovered1"><a name="line750"></a>750 else a + b
1351
- </span><span class="uncovered0"><a name="line751"></a>751 End
1352
- </span><span class="uncovered1"><a name="line752"></a>752 assert_equal(expected, prog(11))
1353
- </span><span class="uncovered0"><a name="line753"></a>753 assert_equal(expected, prog(15))
1354
- </span><span class="uncovered1"><a name="line754"></a>754 assert_equal(expected, prog(31))
1355
- </span><span class="uncovered0"><a name="line755"></a>755 end
1356
- </span><span class="uncovered1"><a name="line756"></a>756
1357
- </span><span class="uncovered0"><a name="line757"></a>757 def test_32
1358
- </span><span class="uncovered1"><a name="line758"></a>758 expected = &lt;&lt;'End'.chomp
1359
- </span><span class="uncovered0"><a name="line759"></a>759 if a == b then a &lt;&lt; 2 else a + b
1360
- </span><span class="uncovered1"><a name="line760"></a>760 End
1361
- </span><span class="uncovered0"><a name="line761"></a>761 assert_equal(expected, prog(32))
1362
- </span><span class="uncovered1"><a name="line762"></a>762 end
1363
- </span><span class="uncovered0"><a name="line763"></a>763
1364
- </span><span class="uncovered1"><a name="line764"></a>764 end
1365
- </span><span class="uncovered0"><a name="line765"></a>765
1366
- </span><span class="uncovered1"><a name="line766"></a>766 class TailGroup &lt; Test::Unit::TestCase # :nodoc:
1367
- </span><span class="uncovered0"><a name="line767"></a>767 def test_1
1368
- </span><span class="uncovered1"><a name="line768"></a>768 out = PrettyPrint.format('', 10) {|q|
1369
- </span><span class="uncovered0"><a name="line769"></a>769 q.group {
1370
- </span><span class="uncovered1"><a name="line770"></a>770 q.group {
1371
- </span><span class="uncovered0"><a name="line771"></a>771 q.text &quot;abc&quot;
1372
- </span><span class="uncovered1"><a name="line772"></a>772 q.breakable
1373
- </span><span class="uncovered0"><a name="line773"></a>773 q.text &quot;def&quot;
1374
- </span><span class="uncovered1"><a name="line774"></a>774 }
1375
- </span><span class="uncovered0"><a name="line775"></a>775 q.group {
1376
- </span><span class="uncovered1"><a name="line776"></a>776 q.text &quot;ghi&quot;
1377
- </span><span class="uncovered0"><a name="line777"></a>777 q.breakable
1378
- </span><span class="uncovered1"><a name="line778"></a>778 q.text &quot;jkl&quot;
1379
- </span><span class="uncovered0"><a name="line779"></a>779 }
1380
- </span><span class="uncovered1"><a name="line780"></a>780 }
1381
- </span><span class="uncovered0"><a name="line781"></a>781 }
1382
- </span><span class="uncovered1"><a name="line782"></a>782 assert_equal(&quot;abc defghi\njkl&quot;, out)
1383
- </span><span class="uncovered0"><a name="line783"></a>783 end
1384
- </span><span class="uncovered1"><a name="line784"></a>784 end
1385
- </span><span class="uncovered0"><a name="line785"></a>785
1386
- </span><span class="uncovered1"><a name="line786"></a>786 class NonString &lt; Test::Unit::TestCase # :nodoc:
1387
- </span><span class="uncovered0"><a name="line787"></a>787 def format(width)
1388
- </span><span class="uncovered1"><a name="line788"></a>788 PrettyPrint.format([], width, 'newline', lambda {|n| &quot;#{n} spaces&quot;}) {|q|
1389
- </span><span class="uncovered0"><a name="line789"></a>789 q.text(3, 3)
1390
- </span><span class="uncovered1"><a name="line790"></a>790 q.breakable(1, 1)
1391
- </span><span class="uncovered0"><a name="line791"></a>791 q.text(3, 3)
1392
- </span><span class="uncovered1"><a name="line792"></a>792 }
1393
- </span><span class="uncovered0"><a name="line793"></a>793 end
1394
- </span><span class="uncovered1"><a name="line794"></a>794
1395
- </span><span class="uncovered0"><a name="line795"></a>795 def test_6
1396
- </span><span class="uncovered1"><a name="line796"></a>796 assert_equal([3, &quot;newline&quot;, &quot;0 spaces&quot;, 3], format(6))
1397
- </span><span class="uncovered0"><a name="line797"></a>797 end
1398
- </span><span class="uncovered1"><a name="line798"></a>798
1399
- </span><span class="uncovered0"><a name="line799"></a>799 def test_7
1400
- </span><span class="uncovered1"><a name="line800"></a>800 assert_equal([3, 1, 3], format(7))
1401
- </span><span class="uncovered0"><a name="line801"></a>801 end
1402
- </span><span class="uncovered1"><a name="line802"></a>802
1403
- </span><span class="uncovered0"><a name="line803"></a>803 end
1404
- </span><span class="uncovered1"><a name="line804"></a>804
1405
- </span><span class="uncovered0"><a name="line805"></a>805 class Fill &lt; Test::Unit::TestCase # :nodoc:
1406
- </span><span class="uncovered1"><a name="line806"></a>806 def format(width)
1407
- </span><span class="uncovered0"><a name="line807"></a>807 PrettyPrint.format('', width) {|q|
1408
- </span><span class="uncovered1"><a name="line808"></a>808 q.group {
1409
- </span><span class="uncovered0"><a name="line809"></a>809 q.text 'abc'
1410
- </span><span class="uncovered1"><a name="line810"></a>810 q.fill_breakable
1411
- </span><span class="uncovered0"><a name="line811"></a>811 q.text 'def'
1412
- </span><span class="uncovered1"><a name="line812"></a>812 q.fill_breakable
1413
- </span><span class="uncovered0"><a name="line813"></a>813 q.text 'ghi'
1414
- </span><span class="uncovered1"><a name="line814"></a>814 q.fill_breakable
1415
- </span><span class="uncovered0"><a name="line815"></a>815 q.text 'jkl'
1416
- </span><span class="uncovered1"><a name="line816"></a>816 q.fill_breakable
1417
- </span><span class="uncovered0"><a name="line817"></a>817 q.text 'mno'
1418
- </span><span class="uncovered1"><a name="line818"></a>818 q.fill_breakable
1419
- </span><span class="uncovered0"><a name="line819"></a>819 q.text 'pqr'
1420
- </span><span class="uncovered1"><a name="line820"></a>820 q.fill_breakable
1421
- </span><span class="uncovered0"><a name="line821"></a>821 q.text 'stu'
1422
- </span><span class="uncovered1"><a name="line822"></a>822 }
1423
- </span><span class="uncovered0"><a name="line823"></a>823 }
1424
- </span><span class="uncovered1"><a name="line824"></a>824 end
1425
- </span><span class="uncovered0"><a name="line825"></a>825
1426
- </span><span class="uncovered1"><a name="line826"></a>826 def test_00_06
1427
- </span><span class="uncovered0"><a name="line827"></a>827 expected = &lt;&lt;'End'.chomp
1428
- </span><span class="uncovered1"><a name="line828"></a>828 abc
1429
- </span><span class="uncovered0"><a name="line829"></a>829 def
1430
- </span><span class="uncovered1"><a name="line830"></a>830 ghi
1431
- </span><span class="uncovered0"><a name="line831"></a>831 jkl
1432
- </span><span class="uncovered1"><a name="line832"></a>832 mno
1433
- </span><span class="uncovered0"><a name="line833"></a>833 pqr
1434
- </span><span class="uncovered1"><a name="line834"></a>834 stu
1435
- </span><span class="uncovered0"><a name="line835"></a>835 End
1436
- </span><span class="uncovered1"><a name="line836"></a>836 assert_equal(expected, format(0))
1437
- </span><span class="uncovered0"><a name="line837"></a>837 assert_equal(expected, format(6))
1438
- </span><span class="uncovered1"><a name="line838"></a>838 end
1439
- </span><span class="uncovered0"><a name="line839"></a>839
1440
- </span><span class="uncovered1"><a name="line840"></a>840 def test_07_10
1441
- </span><span class="uncovered0"><a name="line841"></a>841 expected = &lt;&lt;'End'.chomp
1442
- </span><span class="uncovered1"><a name="line842"></a>842 abc def
1443
- </span><span class="uncovered0"><a name="line843"></a>843 ghi jkl
1444
- </span><span class="uncovered1"><a name="line844"></a>844 mno pqr
1445
- </span><span class="uncovered0"><a name="line845"></a>845 stu
1446
- </span><span class="uncovered1"><a name="line846"></a>846 End
1447
- </span><span class="uncovered0"><a name="line847"></a>847 assert_equal(expected, format(7))
1448
- </span><span class="uncovered1"><a name="line848"></a>848 assert_equal(expected, format(10))
1449
- </span><span class="uncovered0"><a name="line849"></a>849 end
1450
- </span><span class="uncovered1"><a name="line850"></a>850
1451
- </span><span class="uncovered0"><a name="line851"></a>851 def test_11_14
1452
- </span><span class="uncovered1"><a name="line852"></a>852 expected = &lt;&lt;'End'.chomp
1453
- </span><span class="uncovered0"><a name="line853"></a>853 abc def ghi
1454
- </span><span class="uncovered1"><a name="line854"></a>854 jkl mno pqr
1455
- </span><span class="uncovered0"><a name="line855"></a>855 stu
1456
- </span><span class="uncovered1"><a name="line856"></a>856 End
1457
- </span><span class="uncovered0"><a name="line857"></a>857 assert_equal(expected, format(11))
1458
- </span><span class="uncovered1"><a name="line858"></a>858 assert_equal(expected, format(14))
1459
- </span><span class="uncovered0"><a name="line859"></a>859 end
1460
- </span><span class="uncovered1"><a name="line860"></a>860
1461
- </span><span class="uncovered0"><a name="line861"></a>861 def test_15_18
1462
- </span><span class="uncovered1"><a name="line862"></a>862 expected = &lt;&lt;'End'.chomp
1463
- </span><span class="uncovered0"><a name="line863"></a>863 abc def ghi jkl
1464
- </span><span class="uncovered1"><a name="line864"></a>864 mno pqr stu
1465
- </span><span class="uncovered0"><a name="line865"></a>865 End
1466
- </span><span class="uncovered1"><a name="line866"></a>866 assert_equal(expected, format(15))
1467
- </span><span class="uncovered0"><a name="line867"></a>867 assert_equal(expected, format(18))
1468
- </span><span class="uncovered1"><a name="line868"></a>868 end
1469
- </span><span class="uncovered0"><a name="line869"></a>869
1470
- </span><span class="uncovered1"><a name="line870"></a>870 def test_19_22
1471
- </span><span class="uncovered0"><a name="line871"></a>871 expected = &lt;&lt;'End'.chomp
1472
- </span><span class="uncovered1"><a name="line872"></a>872 abc def ghi jkl mno
1473
- </span><span class="uncovered0"><a name="line873"></a>873 pqr stu
1474
- </span><span class="uncovered1"><a name="line874"></a>874 End
1475
- </span><span class="uncovered0"><a name="line875"></a>875 assert_equal(expected, format(19))
1476
- </span><span class="uncovered1"><a name="line876"></a>876 assert_equal(expected, format(22))
1477
- </span><span class="uncovered0"><a name="line877"></a>877 end
1478
- </span><span class="uncovered1"><a name="line878"></a>878
1479
- </span><span class="uncovered0"><a name="line879"></a>879 def test_23_26
1480
- </span><span class="uncovered1"><a name="line880"></a>880 expected = &lt;&lt;'End'.chomp
1481
- </span><span class="uncovered0"><a name="line881"></a>881 abc def ghi jkl mno pqr
1482
- </span><span class="uncovered1"><a name="line882"></a>882 stu
1483
- </span><span class="uncovered0"><a name="line883"></a>883 End
1484
- </span><span class="uncovered1"><a name="line884"></a>884 assert_equal(expected, format(23))
1485
- </span><span class="uncovered0"><a name="line885"></a>885 assert_equal(expected, format(26))
1486
- </span><span class="uncovered1"><a name="line886"></a>886 end
1487
- </span><span class="uncovered0"><a name="line887"></a>887
1488
- </span><span class="uncovered1"><a name="line888"></a>888 def test_27
1489
- </span><span class="uncovered0"><a name="line889"></a>889 expected = &lt;&lt;'End'.chomp
1490
- </span><span class="uncovered1"><a name="line890"></a>890 abc def ghi jkl mno pqr stu
1491
- </span><span class="uncovered0"><a name="line891"></a>891 End
1492
- </span><span class="uncovered1"><a name="line892"></a>892 assert_equal(expected, format(27))
1493
- </span><span class="uncovered0"><a name="line893"></a>893 end
1494
- </span><span class="uncovered1"><a name="line894"></a>894
1495
- </span><span class="uncovered0"><a name="line895"></a>895 end
1496
- </span><span class="uncovered1"><a name="line896"></a>896 end
1497
- </span></pre><hr/>
1498
- <p>Generated using the <a href='http://eigenclass.org/hiki.rb?rcov'>rcov code coverage analysis tool for Ruby</a>
1499
- version 0.8.1.2.</p>
1500
- <p><a href='http://validator.w3.org/check/referer'><img src='http://www.w3.org/Icons/valid-xhtml10' height='31' alt='Valid XHTML 1.0!' width='88'/>
1501
- </a>
1502
- <a href='http://jigsaw.w3.org/css-validator/check/referer'><img src='http://jigsaw.w3.org/css-validator/images/vcss' alt='Valid CSS!' style='border:0;width:88px;height:31px'/>
1503
- </a>
1504
- </p>
1505
- </body>
1506
- </html>