xref: /openbsd-src/gnu/usr.bin/perl/cpan/Text-Tabs/t/sep.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 = is= a= test
14END
15TEST2
16This is a test of a very long line.  It should be broken up and put onto multiple lines.
17This is a test of a very long line.  It should be broken up and put onto multiple lines.
18
19This is a test of a very long line.  It should be broken up and put onto multiple lines.
20END
21   This is a test of a very long line.	It should be broken up and put onto= multiple lines.= This is a test of a very long line.  It should be broken up and put onto= multiple lines.= = This is a test of a very long line.  It should be broken up and put onto= multiple lines.
22END
23TEST3
24This is a test of a very long line.  It should be broken up and put onto multiple lines.
25END
26   This is a test of a very long line.	It should be broken up and put onto= multiple lines.
27END
28TEST4
29This is a test of a very long line.  It should be broken up and put onto multiple lines.
30
31END
32   This is a test of a very long line.	It should be broken up and put onto= multiple lines.
33
34END
35TEST5
36This 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
37END
38   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
39END
40TEST6
4111111111 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
42END
43   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
44END
45TEST7
46c3t1d0s6 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
47END
48   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
49END
50TEST8
51A test of a very very long word.
52a123456789b123456789c123456789d123456789e123456789f123456789g123456789g1234567
53END
54   A test of a very very long word.= a123456789b123456789c123456789d123456789e123456789f123456789g123456789g123= 4567
55END
56TEST9
57A test of a very very long word.  a123456789b123456789c123456789d123456789e123456789f123456789g123456789g1234567
58END
59   A test of a very very long word. = a123456789b123456789c123456789d123456789e123456789f123456789g123456789g123= 4567
60END
61TEST10
62my mother once said
63"never eat paste my darling"
64would that I heeded
65END
66   my mother once said= "never eat paste my darling"= would that I heeded
67END
68TEST11
69This_is_a_word_that_is_too_long_to_wrap_we_want_to_make_sure_that_the_program_does_not_crash_and_burn
70END
71   This_is_a_word_that_is_too_long_to_wrap_we_want_to_make_sure_that_the_pr= ogram_does_not_crash_and_burn
72END
73TEST12
74This
75
76Has
77
78Blank
79
80Lines
81
82END
83   This= = Has= = Blank= = Lines
84
85END
86DONE
87
88
89print "1..", 1 +@tests, "\n";
90
91$Text::Wrap::separator = '=';
92
93my @st;
94
95@st = @tests;
96while (@st) {
97	my $in = shift(@st);
98	my $out = shift(@st);
99
100	$in =~ s/^TEST(\d+)?\n//;
101
102	my $back = wrap('   ', ' ', $in);
103
104	ok( $back eq $out );
105
106}
107
108@st = @tests;
109while(@st) {
110	my $in = shift(@st);
111	my $out = shift(@st);
112
113	$in =~ s/^TEST(\d+)?\n//;
114
115	my @in = split("\n", $in, -1);
116	@in = ((map { "$_\n" } @in[0..$#in-1]), $in[-1]);
117
118	my $back = wrap('   ', ' ', @in);
119
120	ok( $back eq $out );
121}
122
123$Text::Wrap::huge = 'overflow';
124
125my $tw = 'This_is_a_word_that_is_too_long_to_wrap_we_want_to_make_sure_that_the_program_does_not_crash_and_burn';
126my $w = wrap('zzz','yyy',$tw);
127ok( $w eq "zzz$tw" );
128
129