1*256a93a4Safresh1use strict; use warnings; 2b39c5158Smillert 3*256a93a4Safresh1BEGIN { require './t/lib/ok.pl' } 4*256a93a4Safresh1use Text::Wrap; 5*256a93a4Safresh1 6*256a93a4Safresh1my @tests = (split(/\nEND\n/s, <<DONE)); 7b39c5158SmillertTEST1 8b39c5158SmillertThis 9b39c5158Smillertis 10b39c5158Smillerta 11b39c5158Smillerttest 12b39c5158SmillertEND 13b39c5158Smillert This = is= a= test 14b39c5158SmillertEND 15b39c5158SmillertTEST2 16b39c5158SmillertThis is a test of a very long line. It should be broken up and put onto multiple lines. 17b39c5158SmillertThis is a test of a very long line. It should be broken up and put onto multiple lines. 18b39c5158Smillert 19b39c5158SmillertThis is a test of a very long line. It should be broken up and put onto multiple lines. 20b39c5158SmillertEND 21b39c5158Smillert 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. 22b39c5158SmillertEND 23b39c5158SmillertTEST3 24b39c5158SmillertThis is a test of a very long line. It should be broken up and put onto multiple lines. 25b39c5158SmillertEND 26b39c5158Smillert This is a test of a very long line. It should be broken up and put onto= multiple lines. 27b39c5158SmillertEND 28b39c5158SmillertTEST4 29b39c5158SmillertThis is a test of a very long line. It should be broken up and put onto multiple lines. 30b39c5158Smillert 31b39c5158SmillertEND 32b39c5158Smillert This is a test of a very long line. It should be broken up and put onto= multiple lines. 33b39c5158Smillert 34b39c5158SmillertEND 35b39c5158SmillertTEST5 36b39c5158SmillertThis 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 37b39c5158SmillertEND 38b39c5158Smillert 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 39b39c5158SmillertEND 40b39c5158SmillertTEST6 41b39c5158Smillert11111111 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 42b39c5158SmillertEND 43b39c5158Smillert 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 44b39c5158SmillertEND 45b39c5158SmillertTEST7 46b39c5158Smillertc3t1d0s6 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 47b39c5158SmillertEND 48b39c5158Smillert 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 49b39c5158SmillertEND 50b39c5158SmillertTEST8 51b39c5158SmillertA test of a very very long word. 52b39c5158Smillerta123456789b123456789c123456789d123456789e123456789f123456789g123456789g1234567 53b39c5158SmillertEND 54b39c5158Smillert A test of a very very long word.= a123456789b123456789c123456789d123456789e123456789f123456789g123456789g123= 4567 55b39c5158SmillertEND 56b39c5158SmillertTEST9 57b39c5158SmillertA test of a very very long word. a123456789b123456789c123456789d123456789e123456789f123456789g123456789g1234567 58b39c5158SmillertEND 59b39c5158Smillert A test of a very very long word. = a123456789b123456789c123456789d123456789e123456789f123456789g123456789g123= 4567 60b39c5158SmillertEND 61b39c5158SmillertTEST10 62b39c5158Smillertmy mother once said 63b39c5158Smillert"never eat paste my darling" 64b39c5158Smillertwould that I heeded 65b39c5158SmillertEND 66b39c5158Smillert my mother once said= "never eat paste my darling"= would that I heeded 67b39c5158SmillertEND 68b39c5158SmillertTEST11 69b39c5158SmillertThis_is_a_word_that_is_too_long_to_wrap_we_want_to_make_sure_that_the_program_does_not_crash_and_burn 70b39c5158SmillertEND 71b39c5158Smillert This_is_a_word_that_is_too_long_to_wrap_we_want_to_make_sure_that_the_pr= ogram_does_not_crash_and_burn 72b39c5158SmillertEND 73b39c5158SmillertTEST12 74b39c5158SmillertThis 75b39c5158Smillert 76b39c5158SmillertHas 77b39c5158Smillert 78b39c5158SmillertBlank 79b39c5158Smillert 80b39c5158SmillertLines 81b39c5158Smillert 82b39c5158SmillertEND 83b39c5158Smillert This= = Has= = Blank= = Lines 84b39c5158Smillert 85b39c5158SmillertEND 86b39c5158SmillertDONE 87b39c5158Smillert 88b39c5158Smillert 89b39c5158Smillertprint "1..", 1 +@tests, "\n"; 90b39c5158Smillert 91b39c5158Smillert$Text::Wrap::separator = '='; 92b39c5158Smillert 93*256a93a4Safresh1my @st; 94b39c5158Smillert 95b39c5158Smillert@st = @tests; 96b39c5158Smillertwhile (@st) { 97b39c5158Smillert my $in = shift(@st); 98b39c5158Smillert my $out = shift(@st); 99b39c5158Smillert 100b39c5158Smillert $in =~ s/^TEST(\d+)?\n//; 101b39c5158Smillert 102b39c5158Smillert my $back = wrap(' ', ' ', $in); 103b39c5158Smillert 104*256a93a4Safresh1 ok( $back eq $out ); 105b39c5158Smillert 106b39c5158Smillert} 107b39c5158Smillert 108b39c5158Smillert@st = @tests; 109b39c5158Smillertwhile(@st) { 110b39c5158Smillert my $in = shift(@st); 111b39c5158Smillert my $out = shift(@st); 112b39c5158Smillert 113b39c5158Smillert $in =~ s/^TEST(\d+)?\n//; 114b39c5158Smillert 115b39c5158Smillert my @in = split("\n", $in, -1); 116b39c5158Smillert @in = ((map { "$_\n" } @in[0..$#in-1]), $in[-1]); 117b39c5158Smillert 118b39c5158Smillert my $back = wrap(' ', ' ', @in); 119b39c5158Smillert 120*256a93a4Safresh1 ok( $back eq $out ); 121b39c5158Smillert} 122b39c5158Smillert 123b39c5158Smillert$Text::Wrap::huge = 'overflow'; 124b39c5158Smillert 125b39c5158Smillertmy $tw = 'This_is_a_word_that_is_too_long_to_wrap_we_want_to_make_sure_that_the_program_does_not_crash_and_burn'; 126b39c5158Smillertmy $w = wrap('zzz','yyy',$tw); 127*256a93a4Safresh1ok( $w eq "zzz$tw" ); 128b39c5158Smillert 129