This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Build Text::Tabs before running mktables, as it needs it
[perl5.git] / ext / Text-Tabs / t / tabs.t
1 #!/usr/old/bin/perl5.004_01 -w
2
3 @tests = (split(/\nEND\n/s, <<DONE));
4 TEST 1 u
5                 x
6 END
7                 x
8 END
9 TEST 2 e
10                 x
11 END
12                 x
13 END
14 TEST 3 e
15         x
16                 y
17                         z
18 END
19         x
20                 y
21                         z
22 END
23 TEST 4 u
24         x
25                 y
26                         z
27 END
28         x
29                 y
30                         z
31 END
32 TEST 5 u
33 This    Is      a       test    of      a       line with many embedded tabs
34 END
35 This    Is      a       test    of      a       line with many embedded tabs
36 END
37 TEST 6 e
38 This    Is      a       test    of      a       line with many embedded tabs
39 END
40 This    Is      a       test    of      a       line with many embedded tabs
41 END
42 TEST 7 u
43             x
44 END
45             x
46 END
47 TEST 8 e
48         
49                 
50         
51
52            
53 END
54         
55                 
56         
57
58            
59 END
60 TEST 9 u
61            
62 END
63            
64 END
65 TEST 10 u
66         
67                 
68         
69
70            
71 END
72         
73                 
74         
75
76            
77 END
78 TEST 11 u
79 foobar                  IN      A               140.174.82.12
80
81 END
82 foobar                  IN      A               140.174.82.12
83
84 END
85 DONE
86
87 $| = 1;
88
89 print "1..";
90 print @tests/2;
91 print "\n";
92
93 use Text::Tabs;
94
95 $rerun = $ENV{'PERL_DL_NONLAZY'} ? 0 : 1;
96
97 $tn = 1;
98 while (@tests) {
99         my $in = shift(@tests);
100         my $out = shift(@tests);
101
102         $in =~ s/^TEST\s*(\d+)?\s*(\S+)?\n//;
103
104         if ($2 eq 'e') {
105                 $f = \&expand;
106                 $fn = 'expand';
107         } else {
108                 $f = \&unexpand;
109                 $fn = 'unexpand';
110         }
111
112         my $back = &$f($in);
113
114         if ($back eq $out) {
115                 print "ok $tn\n";
116         } elsif ($rerun) {
117                 my $oi = $in;
118                 foreach ($in, $back, $out) {
119                         s/\t/^I\t/gs;
120                         s/\n/\$\n/gs;
121                 }
122                 print "------------ input ------------\n";
123                 print $in;
124                 print "\$\n------------ $fn -----------\n";
125                 print $back;
126                 print "\$\n------------ expected ---------\n";
127                 print $out;
128                 print "\$\n-------------------------------\n";
129                 $Text::Tabs::debug = 1;
130                 my $back = &$f($in);
131                 exit(1);
132         } else {
133                 print "not ok $tn\n";
134         }
135         $tn++;
136 }