xref: /openbsd-src/gnu/usr.bin/perl/cpan/Text-Tabs/t/sep2.t (revision 256a93a44f36679bee503f12e49566c2183f6181)
1use strict; use warnings;
2
3BEGIN { require './t/lib/ok.pl' }
4use Text::Wrap;
5
6my @tests = (split(/\nEND\n/s, <<DONE));
7TEST1
8This
9is
10a
11test
12END
13   This
14 is
15 a
16 test
17END
18TEST2
19This is a test of a very long line.  It should be broken up and put onto multiple lines.
20This is a test of a very long line.  It should be broken up and put onto multiple lines.
21
22This is a test of a very long line.  It should be broken up and put onto multiple lines.
23END
24   This is a test of a very long line.	It should be broken up and put onto= multiple lines.
25 This is a test of a very long line.  It should be broken up and put onto= multiple lines.
26
27 This is a test of a very long line.  It should be broken up and put onto= multiple lines.
28END
29TEST3
30This is a test of a very long line.  It should be broken up and put onto multiple lines.
31END
32   This is a test of a very long line.	It should be broken up and put onto= multiple lines.
33END
34TEST4
35This is a test of a very long line.  It should be broken up and put onto multiple lines.
36
37END
38   This is a test of a very long line.	It should be broken up and put onto= multiple lines.
39
40END
41TEST5
42This is a test of a very long line. It should be broken up and put onto multiple This is a test of a very long line. It should be broken up and put
43END
44   This is a test of a very long line. It should be broken up and put onto= multiple This is a test of a very long line. It should be broken up and= put
45END
46TEST6
4711111111 22222222 33333333 44444444 55555555 66666666 77777777 888888888 999999999 aaaaaaaaa bbbbbbbbb ccccccccc ddddddddd eeeeeeeee ffffffff gggggggg hhhhhhhh iiiiiiii jjjjjjjj kkkkkkkk llllllll mmmmmmmmm nnnnnnnnn ooooooooo ppppppppp qqqqqqqqq rrrrrrrrr sssssssss
48END
49   11111111 22222222 33333333 44444444 55555555 66666666 77777777 888888888= 999999999 aaaaaaaaa bbbbbbbbb ccccccccc ddddddddd eeeeeeeee ffffffff= gggggggg hhhhhhhh iiiiiiii jjjjjjjj kkkkkkkk llllllll mmmmmmmmm nnnnnnnnn= ooooooooo ppppppppp qqqqqqqqq rrrrrrrrr sssssssss
50END
51TEST7
52c3t1d0s6 c4t1d0s6 c5t1d0s6 c6t1d0s6 c7t1d0s6 c8t1d0s6 c9t1d0s6 c10t1d0s6 c11t1d0s6 c12t1d0s6 c13t1d0s6 c14t1d0s6 c15t1d0s6 c16t1d0s6 c3t1d0s0 c4t1d0s0 c5t1d0s0 c6t1d0s0 c7t1d0s0 c8t1d0s0 c9t1d0s0 c10t1d0s0 c11t1d0s0 c12t1d0s0 c13t1d0s0 c14t1d0s0 c15t1d0s0 c16t1d0s0
53END
54   c3t1d0s6 c4t1d0s6 c5t1d0s6 c6t1d0s6 c7t1d0s6 c8t1d0s6 c9t1d0s6 c10t1d0s6= c11t1d0s6 c12t1d0s6 c13t1d0s6 c14t1d0s6 c15t1d0s6 c16t1d0s6 c3t1d0s0= c4t1d0s0 c5t1d0s0 c6t1d0s0 c7t1d0s0 c8t1d0s0 c9t1d0s0 c10t1d0s0 c11t1d0s0= c12t1d0s0 c13t1d0s0 c14t1d0s0 c15t1d0s0 c16t1d0s0
55END
56TEST8
57A test of a very very long word.
58a123456789b123456789c123456789d123456789e123456789f123456789g123456789g1234567
59END
60   A test of a very very long word.
61 a123456789b123456789c123456789d123456789e123456789f123456789g123456789g123= 4567
62END
63TEST9
64A test of a very very long word.  a123456789b123456789c123456789d123456789e123456789f123456789g123456789g1234567
65END
66   A test of a very very long word. = a123456789b123456789c123456789d123456789e123456789f123456789g123456789g123= 4567
67END
68TEST10
69my mother once said
70"never eat paste my darling"
71would that I heeded
72END
73   my mother once said
74 "never eat paste my darling"
75 would that I heeded
76END
77TEST11
78This_is_a_word_that_is_too_long_to_wrap_we_want_to_make_sure_that_the_program_does_not_crash_and_burn
79END
80   This_is_a_word_that_is_too_long_to_wrap_we_want_to_make_sure_that_the_pr= ogram_does_not_crash_and_burn
81END
82TEST12
83This
84
85Has
86
87Blank
88
89Lines
90
91END
92   This
93
94 Has
95
96 Blank
97
98 Lines
99
100END
101DONE
102
103
104print "1..", 1 +@tests, "\n";
105
106$Text::Wrap::separator2 = '=';
107
108my @st;
109
110@st = @tests;
111while (@st) {
112	my $in = shift(@st);
113	my $out = shift(@st);
114
115	$in =~ s/^TEST(\d+)?\n//;
116
117	my $back = wrap('   ', ' ', $in);
118
119	ok( $back eq $out );
120
121}
122
123@st = @tests;
124while(@st) {
125	my $in = shift(@st);
126	my $out = shift(@st);
127
128	$in =~ s/^TEST(\d+)?\n//;
129
130	my @in = split("\n", $in, -1);
131	@in = ((map { "$_\n" } @in[0..$#in-1]), $in[-1]);
132
133	my $back = wrap('   ', ' ', @in);
134
135	ok( $back eq $out );
136}
137
138$Text::Wrap::huge = 'overflow';
139
140my $tw = 'This_is_a_word_that_is_too_long_to_wrap_we_want_to_make_sure_that_the_program_does_not_crash_and_burn';
141my $w = wrap('zzz','yyy',$tw);
142ok( $w eq "zzz$tw" );
143
144