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