| Line | |
|---|
| 1 | #!./perl -w
|
|---|
| 2 |
|
|---|
| 3 | BEGIN {
|
|---|
| 4 | chdir 't' if -d 't';
|
|---|
| 5 | @INC = '../lib';
|
|---|
| 6 | }
|
|---|
| 7 |
|
|---|
| 8 | @tests = (split(/\nEND\n/s, <<DONE));
|
|---|
| 9 | TEST 1 u
|
|---|
| 10 | x
|
|---|
| 11 | END
|
|---|
| 12 | x
|
|---|
| 13 | END
|
|---|
| 14 | TEST 2 e
|
|---|
| 15 | x
|
|---|
| 16 | END
|
|---|
| 17 | x
|
|---|
| 18 | END
|
|---|
| 19 | TEST 3 e
|
|---|
| 20 | x
|
|---|
| 21 | y
|
|---|
| 22 | z
|
|---|
| 23 | END
|
|---|
| 24 | x
|
|---|
| 25 | y
|
|---|
| 26 | z
|
|---|
| 27 | END
|
|---|
| 28 | TEST 4 u
|
|---|
| 29 | x
|
|---|
| 30 | y
|
|---|
| 31 | z
|
|---|
| 32 | END
|
|---|
| 33 | x
|
|---|
| 34 | y
|
|---|
| 35 | z
|
|---|
| 36 | END
|
|---|
| 37 | TEST 5 u
|
|---|
| 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 6 e
|
|---|
| 43 | This Is a test of a line with many embedded tabs
|
|---|
| 44 | END
|
|---|
| 45 | This Is a test of a line with many embedded tabs
|
|---|
| 46 | END
|
|---|
| 47 | TEST 7 u
|
|---|
| 48 | x
|
|---|
| 49 | END
|
|---|
| 50 | x
|
|---|
| 51 | END
|
|---|
| 52 | TEST 8 e
|
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 | END
|
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 | END
|
|---|
| 65 | TEST 9 u
|
|---|
| 66 |
|
|---|
| 67 | END
|
|---|
| 68 |
|
|---|
| 69 | END
|
|---|
| 70 | TEST 10 u
|
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
|
|---|
| 75 |
|
|---|
| 76 | END
|
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 | END
|
|---|
| 83 | TEST 11 u
|
|---|
| 84 | foobar IN A 140.174.82.12
|
|---|
| 85 |
|
|---|
| 86 | END
|
|---|
| 87 | foobar IN A 140.174.82.12
|
|---|
| 88 |
|
|---|
| 89 | END
|
|---|
| 90 | DONE
|
|---|
| 91 |
|
|---|
| 92 | $| = 1;
|
|---|
| 93 |
|
|---|
| 94 | my $testcount = "1..";
|
|---|
| 95 | $testcount .= @tests/2;
|
|---|
| 96 | print "$testcount\n";
|
|---|
| 97 |
|
|---|
| 98 | use Text::Tabs;
|
|---|
| 99 |
|
|---|
| 100 | $rerun = $ENV{'PERL_DL_NONLAZY'} ? 0 : 1;
|
|---|
| 101 |
|
|---|
| 102 | $tn = 1;
|
|---|
| 103 | while (@tests) {
|
|---|
| 104 | my $in = shift(@tests);
|
|---|
| 105 | my $out = shift(@tests);
|
|---|
| 106 |
|
|---|
| 107 | $in =~ s/^TEST\s*(\d+)?\s*(\S+)?\n//;
|
|---|
| 108 |
|
|---|
| 109 | if ($2 eq 'e') {
|
|---|
| 110 | $f = \&expand;
|
|---|
| 111 | $fn = 'expand';
|
|---|
| 112 | } else {
|
|---|
| 113 | $f = \&unexpand;
|
|---|
| 114 | $fn = 'unexpand';
|
|---|
| 115 | }
|
|---|
| 116 |
|
|---|
| 117 | my $back = &$f($in);
|
|---|
| 118 |
|
|---|
| 119 | if ($back eq $out) {
|
|---|
| 120 | print "ok $tn\n";
|
|---|
| 121 | } elsif ($rerun) {
|
|---|
| 122 | my $oi = $in;
|
|---|
| 123 | foreach ($in, $back, $out) {
|
|---|
| 124 | s/\t/^I\t/gs;
|
|---|
| 125 | s/\n/\$\n/gs;
|
|---|
| 126 | }
|
|---|
| 127 | print "------------ input ------------\n";
|
|---|
| 128 | print $in;
|
|---|
| 129 | print "\$\n------------ $fn -----------\n";
|
|---|
| 130 | print $back;
|
|---|
| 131 | print "\$\n------------ expected ---------\n";
|
|---|
| 132 | print $out;
|
|---|
| 133 | print "\$\n-------------------------------\n";
|
|---|
| 134 | $Text::Tabs::debug = 1;
|
|---|
| 135 | my $back = &$f($in);
|
|---|
| 136 | exit(1);
|
|---|
| 137 | } else {
|
|---|
| 138 | print "not ok $tn\n";
|
|---|
| 139 | }
|
|---|
| 140 | $tn++;
|
|---|
| 141 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.