dslinux/user/perl/lib/Text/TabsWrap/t fill.t tabs.t wrap.t

cayenne dslinux_cayenne at user.in-berlin.de
Mon Dec 4 18:01:13 CET 2006


Update of /cvsroot/dslinux/dslinux/user/perl/lib/Text/TabsWrap/t
In directory antilope:/tmp/cvs-serv17422/lib/Text/TabsWrap/t

Added Files:
	fill.t tabs.t wrap.t 
Log Message:
Adding fresh perl source to HEAD to branch from

--- NEW FILE: tabs.t ---
#!./perl -w

BEGIN {
    chdir 't' if -d 't';
    @INC = '../lib';
}

@tests = (split(/\nEND\n/s, <<DONE));
TEST 1 u
                x
END
		x
END
TEST 2 e
		x
END
                x
END
TEST 3 e
	x
		y
			z
END
        x
                y
                        z
END
TEST 4 u
        x
                y
                        z
END
	x
		y
			z
END
TEST 5 u
This    Is      a       test    of      a       line with many embedded tabs
END
This	Is	a	test	of	a	line with many embedded tabs
END
TEST 6 e
This	Is	a	test	of	a	line with many embedded tabs
END
This    Is      a       test    of      a       line with many embedded tabs
END
TEST 7 u
            x
END
	    x
END
TEST 8 e
	
		
   	

           
END
        
                
        

           
END
TEST 9 u
           
END
	   
END
TEST 10 u
	
		
   	

           
END
	
		
	

	   
END
TEST 11 u
foobar                  IN	A		140.174.82.12

END
foobar			IN	A		140.174.82.12

END
DONE

$| = 1;

my $testcount = "1..";
$testcount .= @tests/2;
print "$testcount\n";

use Text::Tabs;

$rerun = $ENV{'PERL_DL_NONLAZY'} ? 0 : 1;

$tn = 1;
while (@tests) {
	my $in = shift(@tests);
	my $out = shift(@tests);

	$in =~ s/^TEST\s*(\d+)?\s*(\S+)?\n//;

	if ($2 eq 'e') {
		$f = \&expand;
		$fn = 'expand';
	} else {
		$f = \&unexpand;
		$fn = 'unexpand';
	}

	my $back = &$f($in);

	if ($back eq $out) {
		print "ok $tn\n";
	} elsif ($rerun) {
		my $oi = $in;
		foreach ($in, $back, $out) {
			s/\t/^I\t/gs;
			s/\n/\$\n/gs;
		}
		print "------------ input ------------\n";
		print $in;
		print "\$\n------------ $fn -----------\n";
		print $back;
		print "\$\n------------ expected ---------\n";
		print $out;
		print "\$\n-------------------------------\n";
		$Text::Tabs::debug = 1;
		my $back = &$f($in);
		exit(1);
	} else {
		print "not ok $tn\n";
	}
	$tn++;
}

--- NEW FILE: wrap.t ---
#!./perl -w

BEGIN {
    chdir 't' if -d 't';
    @INC = '../lib';
}

@tests = (split(/\nEND\n/s, <<'DONE'));
TEST1
This 
is
a
test
END
   This 
 is
 a
 test
END
TEST2
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.
END
   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.
END
TEST3
This is a test of a very long line.  It should be broken up and put onto multiple lines.
END
   This is a test of a very long line.	It should be broken up and put onto
 multiple lines.
END
TEST4
This is a test of a very long line.  It should be broken up and put onto multiple lines.

END
   This is a test of a very long line.	It should be broken up and put onto
 multiple lines.

END
TEST5
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
END
   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
END
TEST6
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
END
   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
END
TEST7
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
END
   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
END
TEST8
A test of a very very long word.
a123456789b123456789c123456789d123456789e123456789f123456789g123456789g1234567
END
   A test of a very very long word.
 a123456789b123456789c123456789d123456789e123456789f123456789g123456789g123
 4567
END
TEST9
A test of a very very long word.  a123456789b123456789c123456789d123456789e123456789f123456789g123456789g1234567
END
   A test of a very very long word. 
 a123456789b123456789c123456789d123456789e123456789f123456789g123456789g123
 4567
END
TEST10
my mother once said
"never eat paste my darling"
would that I heeded
END
   my mother once said
 "never eat paste my darling"
 would that I heeded
END
TEST11
This_is_a_word_that_is_too_long_to_wrap_we_want_to_make_sure_that_the_program_does_not_crash_and_burn
END
   This_is_a_word_that_is_too_long_to_wrap_we_want_to_make_sure_that_the_pr
 ogram_does_not_crash_and_burn
END
TEST12
This

Has

Blank

Lines

END
   This
 
 Has
 
 Blank
 
 Lines

END
TEST13 break=\d
I saw 3 ships come sailing in
END
   I saw 3 ships come sailing in
END
TEST14 break=\d
the.quick.brown.fox.jumps.over.the.9.lazy.dogs.for.no.good.reason.whatsoever.apparently
END
   the.quick.brown.fox.jumps.over.the.
 .lazy.dogs.for.no.good.reason.whatsoever.apparently
END
DONE


$| = 1;

print "1..", 2 + at tests, "\n";

use Text::Wrap;

$rerun = $ENV{'PERL_DL_NONLAZY'} ? 0 : 1;

$tn = 1;

@st = @tests;
while (@st) {
	my $in = shift(@st);
	my $out = shift(@st);

	$in =~ s/^TEST(\d+)( break=(.*))?\n//
	    or die "bad TEST header line: $in\n";
	local $Text::Wrap::break = $3 if defined $3;

	my $back = wrap('   ', ' ', $in);

	if ($back eq $out) {
		print "ok $tn\n";
	} elsif ($rerun) {
		my $oi = $in;
		foreach ($in, $back, $out) {
			s/\t/^I\t/gs;
			s/\n/\$\n/gs;
		}
		print "------------ input ------------\n";
		print $in;
		print "\n------------ output -----------\n";
		print $back;
		print "\n------------ expected ---------\n";
		print $out;
		print "\n-------------------------------\n";
		$Text::Wrap::debug = 1;
		wrap('   ', ' ', $oi);
		exit(1);
	} else {
		print "not ok $tn\n";
	}
	$tn++;

}

@st = @tests;
while(@st) {
	my $in = shift(@st);
	my $out = shift(@st);

	$in =~ s/^TEST(\d+)( break=(.*))?\n//
	    or die "bad TEST header line: $in\n";
	local $Text::Wrap::break = $3 if defined $3;


	my @in = split("\n", $in, -1);
	@in = ((map { "$_\n" } @in[0..$#in-1]), $in[-1]);
	
	my $back = wrap('   ', ' ', @in);

	if ($back eq $out) {
		print "ok $tn\n";
	} elsif ($rerun) {
		my $oi = $in;
		foreach ($in, $back, $out) {
			s/\t/^I\t/gs;
			s/\n/\$\n/gs;
		}
		print "------------ input2 ------------\n";
		print $in;
		print "\n------------ output2 -----------\n";
		print $back;
		print "\n------------ expected2 ---------\n";
		print $out;
		print "\n-------------------------------\n";
		$Text::Wrap::debug = 1;
		wrap('   ', ' ', $oi);
		exit(1);
	} else {
		print "not ok $tn\n";
	}
	$tn++;
}

$Text::Wrap::huge = 'overflow';

my $tw = 'This_is_a_word_that_is_too_long_to_wrap_we_want_to_make_sure_that_the_program_does_not_crash_and_burn';
my $w = wrap('zzz','yyy',$tw);
print (($w eq "zzz$tw") ? "ok $tn\n" : "not ok $tn");
$tn++;

{
    local $Text::Wrap::columns = 10;
    local $Text::Wrap::huge = "wrap";
    print ((wrap("verylongindent", "", "foo") eq "verylongindent\nfoo") ? "ok $tn\n" : "not ok $tn");
    $tn++;
}

--- NEW FILE: fill.t ---
#!./perl -w

BEGIN {
    chdir 't' if -d 't';
    @INC = '../lib';
}

use Text::Wrap qw(&fill);

@tests = (split(/\nEND\n/s, <<DONE));
TEST1
Cyberdog Information

Cyberdog & Netscape in the news
Important Press Release regarding Cyberdog and Netscape. Check it out! 

Cyberdog Plug-in Support!
Cyberdog support for Netscape Plug-ins is now available to download! Go
to the Cyberdog Beta Download page and download it now! 

Cyberdog Book
Check out Jesse Feiler's way-cool book about Cyberdog. You can find
details out about the book as well as ordering information at Philmont
Software Mill site. 

Java!
Looking to view Java applets in Cyberdog 1.1 Beta 3? Download and install
the Mac OS Runtime for Java and try it out! 

Cyberdog 1.1 Beta 3
We hope that Cyberdog and OpenDoc 1.1 will be available within the next
two weeks. In the meantime, we have released another version of
Cyberdog, Cyberdog 1.1 Beta 3. This version fixes several bugs that were
reported to us during out public beta period. You can check out our release
notes to see what we fixed! 
END
    Cyberdog Information
    Cyberdog & Netscape in the news Important Press Release regarding
 Cyberdog and Netscape. Check it out! 
    Cyberdog Plug-in Support! Cyberdog support for Netscape Plug-ins is now
 available to download! Go to the Cyberdog Beta Download page and download
 it now! 
    Cyberdog Book Check out Jesse Feiler's way-cool book about Cyberdog.
 You can find details out about the book as well as ordering information at
 Philmont Software Mill site. 
    Java! Looking to view Java applets in Cyberdog 1.1 Beta 3? Download and
 install the Mac OS Runtime for Java and try it out! 
    Cyberdog 1.1 Beta 3 We hope that Cyberdog and OpenDoc 1.1 will be
 available within the next two weeks. In the meantime, we have released
 another version of Cyberdog, Cyberdog 1.1 Beta 3. This version fixes
 several bugs that were reported to us during out public beta period. You
 can check out our release notes to see what we fixed! 
END
DONE


$| = 1;

print "1..", @tests/2, "\n";

use Text::Wrap;

$rerun = $ENV{'PERL_DL_NONLAZY'} ? 0 : 1;

$tn = 1;
while (@tests) {
	my $in = shift(@tests);
	my $out = shift(@tests);

	$in =~ s/^TEST(\d+)?\n//;

	my $back = fill('    ', ' ', $in);

	if ($back eq $out) {
		print "ok $tn\n";
	} elsif ($rerun) {
		my $oi = $in;
 		write_file("#o", $back);
 		write_file("#e", $out);
		foreach ($in, $back, $out) {
			s/\t/^I\t/gs;
			s/\n/\$\n/gs;
		}
		print "------------ input ------------\n";
		print $in;
		print "\n------------ output -----------\n";
		print $back;
		print "\n------------ expected ---------\n";
		print $out;
		print "\n-------------------------------\n";
		$Text::Wrap::debug = 1;
		fill('    ', ' ', $oi);
		exit(1);
	} else {
		print "not ok $tn\n";
	}
	$tn++;
}

sub write_file
{
	my ($f, @data) = @_;

	local(*F);

	open(F, ">$f") || die "open >$f: $!";
	(print F @data) || die "write $f: $!";
	close(F) || die "close $f: $!";
	return 1;
}




More information about the dslinux-commit mailing list