summaryrefslogtreecommitdiff
path: root/macros/texinfo/texinfo/tp/t/paragraph.t
blob: 198cfa33db135859693d2a79d58022de469feb24 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
use strict;

use Test::More;
use File::Spec;
use File::Basename;

use lib '.';
use Texinfo::ModulePath (undef, undef, 'updirs' => 2);

BEGIN { plan tests => 119 ; }

use Texinfo::Convert::Paragraph;
use Texinfo::Convert::Line;
use Texinfo::Convert::UnFilled;

ok(1, "modules loading"); # If we made it this far, we're ok.

sub test_para($$$;$)
{
  my $args = shift;
  my $reference = shift;
  my $name = shift;
  my $conf = shift;

  my $result = '';
  #$conf = {'DEBUG' => 1} if (!defined($conf));
  $conf = {} if (!defined($conf));
  my $para = Texinfo::Convert::Paragraph->new($conf);
  foreach my $arg (@$args) {
    $result .= add_text($para, $arg);
  }
  $result .= Texinfo::Convert::Paragraph::end($para);
  if (defined($reference)) {
    is ($result, $reference, $name);
  } else {
    print STDERR "$result\n";
  }
}

test_para(['word'], "word\n", 'word');
test_para(['word other'], "word other\n", 'two_words');
test_para(['word  other'], "word other\n", 'two_words two spaces');
test_para(['word ', ' other'], "word other\n", 'two_words feed, space inside');
test_para(['word '], "word\n", 'trailing spaces');
test_para([' word'], "word\n", 'leading spaces');
test_para([' ', ' word'], "word\n", 'double leading spaces');
test_para(["word\n", "a"], "word a\n", 'trailing end of line and word');
test_para(['word', "\n", "a"], "word a\n", 'appended end of line and word');
test_para(['word other'], "word\nother\n", 'two_words_max', {'max' => 2});
test_para(['word other'], "word\nother\n", 'two_words_max_less_one', {'max' => 3});
test_para(['word other'], "word\nother\n", 'two_words_max_exact', {'max' => 4});
test_para(['word other'], "word\nother\n", 'two_words_max_plus_one', {'max' => 5});
test_para(['word other'], "word\nother\n", 'two_words_max_plus_two', {'max' => 6});
test_para(['word o'], "word\no\n", 'word_letter_max_exact', {'max' => 5});
test_para(['word o'], "word o\n", 'word_letter_max_plus_two', {'max' => 6});
test_para(['word  other'], "word other\n", 'two_words_two_spaces');
test_para(['word.  other'], "word.  other\n", 'two_words_dot');
#test_para(['word. other'], "word.  other\n", 'two_words_dot_one_space');
test_para(['word. other'], "word.  other\n", 'two_words_dot_one_space');
test_para(['word.) other'], "word.)  other\n", 'two_words_dot_paren_one_space');
test_para(['word.). other'], "word.).  other\n", 'two_words_dot_paren_dot');
test_para(['word.. other'], "word..  other\n", 'two_words_dot_dot');
test_para(['worD.  other'], "worD. other\n", 'two_words_dot_upper');
test_para(['worD.)  other'], "worD.) other\n", 'two_words_dot_paren_upper');
test_para(['worD).  other'], "worD). other\n", 'two_words_paren_dot_upper');
test_para(["word.\n", "\n", "\n", 'other',], "word.  other\n", 'three_newlines');
test_para(['word','other'], "wordother\n", 'concatenate');
test_para(['word.', ' A'], "word.  A\n", 'punctuation_at_end_fragment');
test_para(['word','other'], "wordother\n", 'concatenate_max', {'max' => 2});
test_para(['word ','other'], "word\nother\n", 'two_elements_max', {'max' => 2});
test_para(['word',' other'], "word\nother\n", 'two_elements_space_max', {'max' => 2});
test_para(["\x{7b2c}\x{4e00} ",'other'], "\x{7b2c}\n\x{4e00}\nother\n", 'east_asian', {'max' => 2});
test_para(['word.  other'], "word. other\n", 'two_words_dot_frenchspacing', {'frenchspacing' => 1});
test_para(["aa.)\x{7b2c} b"], "aa.)\x{7b2c} b\n", 'end_sentence_east_asian');
test_para(["aaaa bbbbbbb cccccccc dddddddddddd eeeeeeeeeeee fffffffff ggggggg"],
"   aaaa
 bbbbbbb
 cccccccc
 dddddddddddd
 eeeeeeeeeeee
 fffffffff
 ggggggg
",
   'indent_indent_next', {'max' => 6, 'indent_length' => 3, 'indent_length_next' => 1});
test_para(["aaaa bbbbbbb cccccccc dddddddddddd eeeeeeeeeeee fffffffff ggggggg"], 
"    aaaa
bbbbbbb
cccccccc
dddddddddddd
eeeeeeeeeeee
fffffffff
ggggggg
",
   'indent_no_indent_next', {'max' => 12, 'indent_length' => 4, 'indent_length_next' => 0});
test_para(["aaaa bbbbbbb cccccccc dddddddddddd eeeeeeeeeeee fffffffff ggggggg"],
"    aaaa
    bbbbbbb
    cccccccc
    dddddddddddd
    eeeeeeeeeeee
    fffffffff
    ggggggg
",
   'indent_undef_indent_next', {'max' => 12, 'indent_length' => 4});
test_para(["aaaa bbbbbbb cccccccc dddddddddddd eeeeeeeeeeee fffffffff ggggggg"], 
"aaaa bbbbbbb
   cccccccc
   dddddddddddd
   eeeeeeeeeeee
   fffffffff
   ggggggg
",
   'indent_next_no_indent', {'max' => 12, 'indent_length' => 0, 'indent_length_next' => 3});
test_para(["aaaa bbbbbbb cccccccc dddddddddddd eeeeeeeeeeee fffffffff ggggggg"],
"aaaa bbbbbbb
   cccccccc
   dddddddddddd
   eeeeeeeeeeee
   fffffffff
   ggggggg
",
   'indent_next_undef_indent', {'max' => 12, 'indent_length_next' => 3});
test_para(["aaaa"], "  aaaa\n", 'indent_and_counter_lower', 
  {'indent_length' => 8, 'counter' => 6});
test_para(["aaaa"], "aaaa\n", 'indent_zero_and_counter', 
  {'indent_length' => 0, 'counter' => 6});
test_para(["aaaa"], "aaaa\n", 'indent_and_counter_higher', 
  {'indent_length' => 3, 'counter' => 6});
test_para(["aaaa bbbbbbb cccccccc dddddddddddd"],
  "aaaa bbbbbbb\ncccccccc dddddddddddd\n",
  "counter_and_line", {'counter' => 60});


my $para = Texinfo::Convert::Paragraph->new();
my $result = '';
$result .= add_text($para, 'aa.)');
$result .= add_next($para, '_');
$result .= add_text($para, ' after');
$result .= Texinfo::Convert::Paragraph::end($para);
is ($result, "aa.)_  after\n", 'add char after end sentence parentheses');

$para = Texinfo::Convert::Paragraph->new();
$result = '';
$result .= add_text($para, 'b ');
$result .= add_next($para, '_');
$result .= add_text($para, '.');
$result .= add_next($para, '_');
$result .= add_text($para, ' after');
$result .= Texinfo::Convert::Paragraph::end($para);
is ($result, "b _._  after\n", 'add char after end sentence');

$para = Texinfo::Convert::Paragraph->new();
$result = '';
$result .= add_next($para, 'a');
$result .= add_next($para, "\n");
$result .= add_next($para, '_');
$result .= Texinfo::Convert::Paragraph::end($para);
is ($result, "a\n_\n", 'add_next: add char after separate end line');

$para = Texinfo::Convert::Paragraph->new();
$result = '';
$result .= add_next($para, "a\n");
$result .= add_next($para, '_');
$result .= Texinfo::Convert::Paragraph::end($para);
is ($result, "a\n_\n", 'add_next: add char after end line');

$para = Texinfo::Convert::Paragraph->new();
$result = '';
$result .= add_text($para, "A");
$result .= add_next($para, '_');
$result .= add_text($para, ".)");
$result .= add_text($para, " Next");
$result .= Texinfo::Convert::Paragraph::end($para);
is ($result, "A_.)  Next\n", 'add_next: period after next, not transparent');

$para = Texinfo::Convert::Paragraph->new();
$result = '';
$result .= add_text($para, "A");
$result .= add_next($para, '_', 1);
$result .= add_text($para, ".)");
$result .= add_text($para, " Next");
$result .= Texinfo::Convert::Paragraph::end($para);
is ($result, "A_.) Next\n", 'add_next: period after next, transparent');

$para = Texinfo::Convert::Paragraph->new();
$result = '';
$result .= add_text($para, "aa.\n");
$result .= set_space_protection($para, undef,undef,undef,1);
$result .= add_next($para, '_');
$result .= add_text($para, "b");
$result .= Texinfo::Convert::Paragraph::end($para);
is ($result, "aa.  _b\n", 'add char after space protection end sentence space');

$para = Texinfo::Convert::Paragraph->new();
$result = '';
$result .= set_space_protection($para, undef,undef,undef,1);
$result .= add_text($para, "b");
$result .= set_space_protection($para, undef,undef,undef,0);
$result .= add_text($para, ". after");
$result .= Texinfo::Convert::Paragraph::end($para);
is ($result, "b.  after\n", 'punctuation after end space protection');

$para = Texinfo::Convert::Paragraph->new();
$result = '';
$result .= set_space_protection($para, undef,undef,undef,1);
$result .= add_text($para, "b.");
$result .= set_space_protection($para, undef,undef,undef,0);
$result .= add_text($para, " follow");
$result .= Texinfo::Convert::Paragraph::end($para);
is ($result, "b. follow\n", 'punctuation before end space protection');

$para = Texinfo::Convert::Paragraph->new();
$result = '';
$result .= set_space_protection($para, undef,undef,undef,1);
$result .= add_text($para, "b.");
$result .= set_space_protection($para, undef,undef,undef,0);
$result .= add_text($para, "  follow");
$result .= Texinfo::Convert::Paragraph::end($para);
is ($result, "b. follow\n", 'punctuation before end space protection 2 space');

$para = Texinfo::Convert::Paragraph->new();
$result = '';
$result .= set_space_protection($para, undef,undef,undef,1);
$result .= add_text($para, "b. ");
$result .= set_space_protection($para, undef,undef,undef,0);
$result .= add_text($para, " follow");
$result .= Texinfo::Convert::Paragraph::end($para);
is ($result, "b. follow\n", 'punctuation space before end space protection');


$para = Texinfo::Convert::Paragraph->new();
$result = '';
$result .= add_text($para, "In w:\n");
$result .= set_space_protection($para, 1,1);
$result .= add_text($para, "Out of code -- out-of-code.   ggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg");
$result .= Texinfo::Convert::Paragraph::end($para);
is ($result, "In w: Out of code -- out-of-code.   ggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg\n", 'space protection after end sentence');

$para = Texinfo::Convert::Paragraph->new();
$result = '';
$result .= add_text($para, "In w:\n");
$result .= set_space_protection($para, 1,1);
$result .= add_text($para, "Out of code -- out-of-code.");
$result .= set_space_protection($para, undef,undef,undef,1);
$result .= add_text($para, "in code");
$result .= Texinfo::Convert::Paragraph::end($para);
is ($result, "In w: Out of code -- out-of-code.in code\n", 'set frenchspacing after space protection');

$para = Texinfo::Convert::Paragraph->new();
$result = '';
$result .= add_text($para, "a ");
$result .= add_next($para, '...', 1);
$result .= add_text($para, "c");
$result .= Texinfo::Convert::Paragraph::end($para);
is ($result, "a ...c\n", 'add end sentence and text');

$para = Texinfo::Convert::Paragraph->new();
$result = '';
$result .= end_line($para);
$result .= add_text($para, ' after');
$result .= Texinfo::Convert::Paragraph::end($para);
is ($result, "\nafter\n", 'space after end_line');
#print STDERR "$result";

$para = Texinfo::Convert::Paragraph->new();
$result = '';
$result .= add_text($para, 'aa.)');
$result .= add_pending_word($para);
is ($result, 'aa.)', 'call add_pending_word');
$result = end_line($para);
is ($result, "\n", 'call end_line after add_pending_word');
$result = Texinfo::Convert::Paragraph::end($para);
is ($result, '', 'call end after end_line');

$para = Texinfo::Convert::Paragraph->new();
$result = '';
$result .= add_text($para, 'aa.)');
$result .= add_pending_word($para);
$result .= add_text($para, ' after');
$result .= Texinfo::Convert::Paragraph::end($para);
is ($result, "aa.)  after\n", 'space after sentence and add_pending_word');

$para = Texinfo::Convert::Paragraph->new();
$result = '';
$result .= add_text($para, 'aA');
$result .= add_next($para, '.');
add_end_sentence($para, 1);
$result .= add_text($para, ' after');
$result .= Texinfo::Convert::Paragraph::end($para);
is ($result, "aA.  after\n", 'force end sentence after upper case');

$para = Texinfo::Convert::Paragraph->new();
$result = '';
$result .= add_text($para, 'aa');
$result .= add_next($para, '.');
add_end_sentence($para, 1);
$result .= add_text($para, 'b c');
$result .= Texinfo::Convert::Paragraph::end($para);
is ($result, "aa.b c\n", 'force end sentence followed by text');

$para = Texinfo::Convert::Paragraph->new();
$result = '';
$result .= add_text($para, 'aA');
$result .= add_text($para, '.');
$result .= add_text($para, ' after');
$result .= Texinfo::Convert::Paragraph::end($para);
is ($result, "aA. after\n", 'end sentence after upper case');

$para = Texinfo::Convert::Paragraph->new();
$result = '';
$result .= add_text($para, 'aa.)');
$result .= add_text($para, '))');
$result .= add_text($para, ' after');
$result .= Texinfo::Convert::Paragraph::end($para);
is ($result, "aa.)))  after\n", 'continue with after_punctuation_characters');

$para = Texinfo::Convert::Paragraph->new();
$result = '';
$result .= add_text($para, 'aa.)');
remove_end_sentence($para, );
$result .= add_text($para, ' after');
$result .= Texinfo::Convert::Paragraph::end($para);
is ($result, "aa.) after\n", 'inhibit end sentence');

$para = Texinfo::Convert::Paragraph->new();
$result = '';
$result .= add_text($para, 'aa.)');
remove_end_sentence($para, );
$result .= add_next($para, '_');
$result .= add_text($para, ' after');
$result .= Texinfo::Convert::Paragraph::end($para);
is ($result, "aa.)_ after\n", 'inhibit end sentence then add next');

$para = Texinfo::Convert::Paragraph->new();
$result = '';
$result .= add_text($para, 'aa.)');
remove_end_sentence($para, );
$result .= add_text($para, 'aa.)');
$result .= add_text($para, ' after');
$result .= Texinfo::Convert::Paragraph::end($para);
is ($result, "aa.)aa.)  after\n", 'cancel inhibit end sentence');

$para = Texinfo::Convert::Paragraph->new();
$result = '';
$result .= add_text($para, 'aa.)');
remove_end_sentence($para, );
$result .= add_text($para, '))');
$result .= add_text($para, ' after');
$result .= Texinfo::Convert::Paragraph::end($para);
is ($result, "aa.))) after\n", 'inhibit end sentence and ))');

$para = Texinfo::Convert::Paragraph->new();
$result = '';
set_space_protection($para, undef,1,1);
$result .= add_text($para, '  aa.) bb.');
$result .= Texinfo::Convert::Paragraph::end($para);
is ($result,"aa.)  bb.\n", 'leading spaces ignore columns and keep spaces');



$para = Texinfo::Convert::Paragraph->new({'max' => 2});
$result = '';
set_space_protection($para, 1,1);
$result .= add_text($para, 'aa.)    bb ');
$result = add_text($para, ' eee ');
$result .= add_text($para, '   .)');
$result .= add_next($para, '_');
$result .= add_text($para, "\n");
$result .= add_text($para, "aa\n");
$result .= add_text($para, ' . gg');
$result .= add_text($para, ". \n");
$result .= add_text($para, "a");
$result .= add_text($para, '  ');
$result .= set_space_protection($para, 0,0);
$result .= add_text($para, "c ");
is ($result, "aa.)    bb  eee    .)_ aa  . gg.  a  c\n", "protected spaces many inputs");
Texinfo::Convert::Paragraph::end($para);

$para = Texinfo::Convert::Paragraph->new({'max' => 10});
$result = '';
$result .= add_next($para, "AAAAAAA");
$result .= add_text($para, "GGG GGG");
$result .= Texinfo::Convert::Paragraph::end($para);
is ($result, "AAAAAAAGGG\nGGG\n", 'line split check');

$para = Texinfo::Convert::Paragraph->new({'max' => 10});
$result = '';
$result .= add_next($para, "AAAAAAA\n");
$result .= add_text($para, "GGG GGG");
$result .= Texinfo::Convert::Paragraph::end($para);
is ($result, "AAAAAAA\nGGG GGG\n", 'end line reset counter');

$para = Texinfo::Convert::Paragraph->new({'indent_length' => 3});
$result = '';
$result .= set_space_protection($para, 1,1);
$result .= add_text($para, " a\n");
$result .= set_space_protection($para, 0,0);
$result .= Texinfo::Convert::Paragraph::end($para);
is ($result, "    a \n", 'end space protection by end line'); 

$para = Texinfo::Convert::Paragraph->new();
$result = '';
$result .= set_space_protection($para, 1,1);
$result .= add_text($para, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbb bbbbb bbb b b b b b b b b b bb .\n");
$result .= add_text($para,  "ccc dddd");
$result .= set_space_protection($para, 0,0);
$result .= add_text($para,  "gg.\n");
$result .= Texinfo::Convert::Paragraph::end($para);
is ($result, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbb bbbbb bbb b b b b b b b b b bb . ccc ddddgg.\n", 'long text followed by text protected'); 

$para = Texinfo::Convert::Paragraph->new();
$result = '';
$result .= add_text($para, 'aa');
$result .= set_space_protection($para, 1,1);
$result .= add_text($para, '  f  f');
$result .= set_space_protection($para, 0,0);
$result .= add_text($para, "ggg\n");
is ($result, 'aa  f  fggg', 'protected space within words');
Texinfo::Convert::Paragraph::end($para);

$para = Texinfo::Convert::Paragraph->new();
$result = '';
$result = add_text($para, 'aa');
$result .= set_space_protection($para, 1,1);
$result .= add_text($para, '  f  f ');
$result .= set_space_protection($para, 0,0);
$result .= add_text($para, "ggg\n");
is ($result, 'aa  f  f ggg', 'protected space and space within words');
Texinfo::Convert::Paragraph::end($para);

$para = Texinfo::Convert::Paragraph->new();
$result = '';
$result = add_text($para, 'aa ');
$result .= set_space_protection($para, 1,1);
$result .= add_text($para, '  f  f ');
$result .= set_space_protection($para, 0,0);
$result .= add_text($para, "ggg\n");
is ($result, 'aa   f  f ggg', 'text space protected space and space within words');
Texinfo::Convert::Paragraph::end($para);

$para = Texinfo::Convert::Paragraph->new();
$result = '';
$result = add_text($para, 'aa ');
$result .= set_space_protection($para, 1,1);
$result .= add_text($para, '  f  f ');
$result .= set_space_protection($para, 0,0);
$result .= add_text($para, " ggg\n");
is ($result, 'aa   f  f  ggg', 'text space protected space and space after');
Texinfo::Convert::Paragraph::end($para);

$para = Texinfo::Convert::Paragraph->new();
$result = '';
$result = add_text($para, 'aa ');
$result .= set_space_protection($para, 1,1);
$result .= set_space_protection($para, 0,0);
$result .= add_text($para, " ggg\n");
is ($result, 'aa  ggg', 'empty protected 2 space');
Texinfo::Convert::Paragraph::end($para);

$para = Texinfo::Convert::Paragraph->new();
$result = '';
$result = add_text($para, 'aa ');
$result .= set_space_protection($para, 1,1);
set_space_protection($para, 0,0);
$result .= add_text($para, "ggg\n");
is ($result, 'aa ggg', 'empty protected 1 before space');
Texinfo::Convert::Paragraph::end($para);

$para = Texinfo::Convert::Paragraph->new();
$result = '';
$result = add_text($para, 'aa');
$result .= set_space_protection($para, 1,1);
$result .= set_space_protection($para, 0,0);
$result .= add_text($para, " ggg\n");
is ($result, 'aa ggg', 'empty protected 1 after space');
Texinfo::Convert::Paragraph::end($para);

$para = Texinfo::Convert::Paragraph->new();
$result = '';
$result = add_text($para, 'aa ');
$result .= set_space_protection($para, 1,1);
$result .= add_text($para, ' ');
$result .= set_space_protection($para, 0,0);
$result .= add_text($para, " ggg\n");
is ($result, 'aa   ggg', 'space protected space');
Texinfo::Convert::Paragraph::end($para);


sub test_line($$$;$)
{
  my $args = shift;
  my $reference = shift;
  my $name = shift;
  my $conf = shift;

  my $result = '';
  #$conf = {'DEBUG' => 1} if (!defined($conf));
  $conf = {} if (!defined($conf));
  my $line = Texinfo::Convert::Line->new($conf);
  foreach my $arg (@$args) {
    $result .= add_text($line, $arg);
  }
  $result .= Texinfo::Convert::Paragraph::end($line);
  is ($result, $reference, "line $name");
  #print STDERR "$result\n";
}

test_line(["word\n"], "word\n", 'word');
test_line(['word other'], "word other", 'two_words');
test_line(['word '], 'word ', 'trailing spaces');
test_line(["word \n"], "word\n", 'trailing spaces eol');
test_line([' word'], "word", 'leading spaces');
test_line([' ', ' word'], "word", 'double leading spaces');
test_line(['word  other'], "word other", 'two_words_two_spaces');
test_line(['word.  other'], "word.  other", 'two_words_dot');
test_line(['word. other'], "word.  other", 'two_words_dot_one_space');
test_line(['word.) other'], "word.)  other", 'two_words_dot_paren_one_space');
test_line(['worD.  other'], "worD. other", 'two_words_dot_upper');
test_line(['word','other',"\n"], "wordother\n", 'concatenate');
test_line(["\x{7b2c}\x{4e00} ","other \n"], "\x{7b2c}\x{4e00} other\n", 'east_asian');
test_line(['word.  other'], "word. other", 'two_words_dot_frenchspacing', {'frenchspacing' => 1});
test_line(["aa.)\x{7b2c} b"], "aa.)\x{7b2c} b", 'end_sentence_east_asian');

my $line = Texinfo::Convert::Line->new();
$result = '';
$result .= add_text($line, 'aa.)');
$result .= add_next($line, '_');
$result .= add_text($line, ' after');
$result .= Texinfo::Convert::Paragraph::end($line);
is ($result, "aa.)_  after", 'line add char after end sentence');

$para = Texinfo::Convert::Line->new();
$result = '';
$result .= end_line($line);
$result .= add_text($line, ' after');
$result .= Texinfo::Convert::Paragraph::end($line);
is ($result, "\nafter", 'line space after end_line');
#print STDERR "$result";

$line = Texinfo::Convert::Line->new();
$result = '';
$result .= add_text($line, "A");
$result .= add_next($line, '_', 1);
$result .= add_text($line, ".)");
$result .= add_text($line, " Next");
$result .= Texinfo::Convert::Paragraph::end($line);
is ($result, "A_.) Next", 'line add_next: period after next, transparent');

$line = Texinfo::Convert::Line->new();
$result = '';
$result .= add_text($line, 'aa.)');
$result .= add_pending_word($line);
is ($result, 'aa.)', 'line call add_pending_word');
$result = end_line($line);
is ($result, "\n", 'line call end_line after add_pending_word');
$result = Texinfo::Convert::Paragraph::end($line);
is ($result, "", 'line call end after end_line');

$para = Texinfo::Convert::Line->new();
$result = '';
$result .= add_text($line, 'aa.)');
$result .= add_pending_word($line);
$result .= add_text($line, ' after');
$result .= Texinfo::Convert::Paragraph::end($line);
is ($result, "aa.)  after", 'line space after sentence and add_pending_word');

$para = Texinfo::Convert::Line->new();
$result = '';
$result .= add_text($line, 'aA');
$result .= add_next($line, '.');
add_end_sentence($line, 1);
$result .= add_text($line, ' after');
$result .= Texinfo::Convert::Paragraph::end($line);
is ($result, "aA.  after", 'line force end sentence after upper case');

$line = Texinfo::Convert::Line->new();
$result = '';
$result .= add_text($line, 'aA');
$result .= add_text($line, '.');
$result .= add_text($line, ' after');
$result .= Texinfo::Convert::Paragraph::end($line);
is ($result, "aA. after", 'line end sentence after upper case');

$line = Texinfo::Convert::Line->new();
$result = '';
$result .= add_text($line, 'aa.)');
$result .= add_text($line, '))');
$result .= add_text($line, ' after');
$result .= Texinfo::Convert::Paragraph::end($line);
is ($result, "aa.)))  after", 'line continue with after_punctuation_characters');

$line = Texinfo::Convert::Line->new();
$result = '';
$result .= add_text($line, 'aa.)');
remove_end_sentence($line, );
$result .= add_text($line, ' after');
$result .= Texinfo::Convert::Paragraph::end($line);
is ($result, "aa.) after", 'line inhibit end sentence');

$line = Texinfo::Convert::Line->new();
$result = '';
$result .= add_text($line, 'aa.)');
remove_end_sentence($line, );
$result .= add_next($line, '_');
$result .= add_text($line, ' after');
$result .= Texinfo::Convert::Paragraph::end($line);
is ($result, "aa.)_ after", 'line inhibit end sentence then add next');

$line = Texinfo::Convert::Line->new();
$result = '';
$result .= add_text($line, 'aa.)');
remove_end_sentence($line, );
$result .= add_text($line, 'aa.)');
$result .= add_text($line, ' after');
$result .= Texinfo::Convert::Paragraph::end($line);
is ($result, "aa.)aa.)  after", 'line cancel inhibit end sentence');

$line = Texinfo::Convert::Line->new();
$result = '';
$result .= add_text($line, 'aa.)');
remove_end_sentence($line, );
$result .= add_text($line, '))');
$result .= add_text($line, ' after');
$result .= Texinfo::Convert::Paragraph::end($line);
is ($result, "aa.))) after", 'line inhibit end sentence and ))');

$line = Texinfo::Convert::Line->new();
$result = '';
set_space_protection($line, 1,1);
$result .= add_text($line, ' aa.)');
$result .= add_text($line, ' ');
$result .= add_text($line, 'then');
$result .= add_text($line, 'fff     g');
set_space_protection($line, 0,0);
$result .= Texinfo::Convert::Paragraph::end($line);
is ($result, " aa.) thenfff     g", 'line space_protection and spaces');

$line = Texinfo::Convert::Line->new();
$result = '';
$result .= add_text($line, "aa. ");
$result .= set_space_protection($line, undef,undef,undef,1);
$result .= add_next($line, '_');
$result .= add_text($line, "b");
$result .= set_space_protection($line, undef,undef,undef,0);
$result .= add_text($line, ". after");
$result .= Texinfo::Convert::Paragraph::end($line);
is ($result, "aa.  _b.  after", 'line add char after space protection end sentence space');

$line = Texinfo::Convert::Line->new();
$result = '';
$result .= set_space_protection($line, undef,undef,undef,1);
$result .= add_text($line, "b.");
$result .= set_space_protection($line, undef,undef,undef,0);
$result .= add_text($line, "  follow");
$result .= Texinfo::Convert::Paragraph::end($line);
is ($result, "b. follow", 'line punctuation before end space protection 2 space');

$line = Texinfo::Convert::Line->new();
$result = '';
$result .= set_space_protection($line, 1,1);
$result .= add_text($line, "protected. B");
$result .= set_space_protection($line, 0,0);
$result .= add_text($line, "  after");
$result .= Texinfo::Convert::Paragraph::end($line);
is ($result, "protected. B after", 'line 2 spaces after end space protection');

$line = Texinfo::Convert::Line->new();
$result = '';
$result .= set_space_protection($line, 1,1);
$result .= add_text($line, "protected");
$result .= set_space_protection($line, 0,0);
$result .= add_text($line, "  after");
$result .= Texinfo::Convert::Paragraph::end($line);
is ($result, "protected after", 'line 2 spaces after end space protection with dot');

1;