xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/lib/Text/TabsWrap/t/fill.t (revision 0:68f95e015346)
1#!./perl -w
2
3BEGIN {
4    chdir 't' if -d 't';
5    @INC = '../lib';
6}
7
8use Text::Wrap qw(&fill);
9
10@tests = (split(/\nEND\n/s, <<DONE));
11TEST1
12Cyberdog Information
13
14Cyberdog & Netscape in the news
15Important Press Release regarding Cyberdog and Netscape. Check it out! 
16
17Cyberdog Plug-in Support!
18Cyberdog support for Netscape Plug-ins is now available to download! Go
19to the Cyberdog Beta Download page and download it now! 
20
21Cyberdog Book
22Check out Jesse Feiler's way-cool book about Cyberdog. You can find
23details out about the book as well as ordering information at Philmont
24Software Mill site. 
25
26Java!
27Looking to view Java applets in Cyberdog 1.1 Beta 3? Download and install
28the Mac OS Runtime for Java and try it out! 
29
30Cyberdog 1.1 Beta 3
31We hope that Cyberdog and OpenDoc 1.1 will be available within the next
32two weeks. In the meantime, we have released another version of
33Cyberdog, Cyberdog 1.1 Beta 3. This version fixes several bugs that were
34reported to us during out public beta period. You can check out our release
35notes to see what we fixed! 
36END
37    Cyberdog Information
38    Cyberdog & Netscape in the news Important Press Release regarding
39 Cyberdog and Netscape. Check it out! 
40    Cyberdog Plug-in Support! Cyberdog support for Netscape Plug-ins is now
41 available to download! Go to the Cyberdog Beta Download page and download
42 it now! 
43    Cyberdog Book Check out Jesse Feiler's way-cool book about Cyberdog.
44 You can find details out about the book as well as ordering information at
45 Philmont Software Mill site. 
46    Java! Looking to view Java applets in Cyberdog 1.1 Beta 3? Download and
47 install the Mac OS Runtime for Java and try it out! 
48    Cyberdog 1.1 Beta 3 We hope that Cyberdog and OpenDoc 1.1 will be
49 available within the next two weeks. In the meantime, we have released
50 another version of Cyberdog, Cyberdog 1.1 Beta 3. This version fixes
51 several bugs that were reported to us during out public beta period. You
52 can check out our release notes to see what we fixed! 
53END
54DONE
55
56
57$| = 1;
58
59print "1..", @tests/2, "\n";
60
61use Text::Wrap;
62
63$rerun = $ENV{'PERL_DL_NONLAZY'} ? 0 : 1;
64
65$tn = 1;
66while (@tests) {
67	my $in = shift(@tests);
68	my $out = shift(@tests);
69
70	$in =~ s/^TEST(\d+)?\n//;
71
72	my $back = fill('    ', ' ', $in);
73
74	if ($back eq $out) {
75		print "ok $tn\n";
76	} elsif ($rerun) {
77		my $oi = $in;
78 		write_file("#o", $back);
79 		write_file("#e", $out);
80		foreach ($in, $back, $out) {
81			s/\t/^I\t/gs;
82			s/\n/\$\n/gs;
83		}
84		print "------------ input ------------\n";
85		print $in;
86		print "\n------------ output -----------\n";
87		print $back;
88		print "\n------------ expected ---------\n";
89		print $out;
90		print "\n-------------------------------\n";
91		$Text::Wrap::debug = 1;
92		fill('    ', ' ', $oi);
93		exit(1);
94	} else {
95		print "not ok $tn\n";
96	}
97	$tn++;
98}
99
100sub write_file
101{
102	my ($f, @data) = @_;
103
104	local(*F);
105
106	open(F, ">$f") || die "open >$f: $!";
107	(print F @data) || die "write $f: $!";
108	close(F) || die "close $f: $!";
109	return 1;
110}
111