5 # Copyright (C) 1999, 2000, 2003, 2005, 2006 Free Software Foundation, Inc.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 $PERL -e 1 > /dev/null 2>&1 || {
26 echo 1>&2 "$0: configure didn't find a usable version of Perl," \
27 "so can't run this test"
32 exec $PERL -w -I$d -MCoreutils -- - << \EOF
36 (my $program_name = $0) =~ s|.*/||;
38 # Turn off localisation of executable's ouput.
39 @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
41 my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n";
45 ['onearg-1', qw(10), {OUT => [(1..10)]}],
47 ['neg-1', qw(-10 10 10), {OUT => [qw(-10 0 10)]}],
48 ['neg-2', qw(-.1 .1 .1), {OUT => [qw(-0.1 0.0 0.1)]}],
49 ['neg-3', qw(1 -1 0), {OUT => [qw(1 0)]}],
50 ['neg-4', qw(1 -1 -1), {OUT => [qw(1 0 -1)]}],
52 ['eq-wid-1', qw(-w 1 -1 -1), {OUT => [qw(01 00 -1)]}],
54 # Prior to 2.0g, this test would fail on e.g., HPUX systems
55 # because it'd end up using %3.1f as the format instead of %4.1f.
56 ['eq-wid-2', qw(-w -.1 .1 .1),{OUT => [qw(-0.1 00.0 00.1)]}],
58 # Prior to coreutils-4.5.11, some of these were not accepted.
59 ['fmt-1', qw(-f %2.1f 1.5 .5 2),{OUT => [qw(1.5 2.0)]}],
60 ['fmt-2', qw(-f %0.1f 1.5 .5 2),{OUT => [qw(1.5 2.0)]}],
61 ['fmt-3', qw(-f %.1f 1.5 .5 2),{OUT => [qw(1.5 2.0)]}],
63 ['fmt-4', qw(-f %3.0f 1 2), {OUT => [' 1', ' 2']}],
64 ['fmt-5', qw(-f %-3.0f 1 2), {OUT => ['1 ', '2 ']}],
65 ['fmt-6', qw(-f %+3.0f 1 2), {OUT => [' +1', ' +2']}],
66 ['fmt-7', qw(-f %0+3.0f 1 2), {OUT => [qw(+01 +02)]}],
67 ['fmt-8', qw(-f %0+.0f 1 2), {OUT => [qw(+1 +2)]}],
68 ['fmt-9', '-f "% -3.0f"', qw(-1 0), {OUT => ['-1 ', ' 0 ']}],
69 ['fmt-a', '-f "% -.0f"',qw(-1 0), {OUT => ['-1', ' 0']}],
72 # Append a newline to each entry in the OUT array.
79 $e->{OUT} = join ("\n", @{$e->{OUT}}) . "\n"
80 if ref $e eq 'HASH' and exists $e->{OUT};
84 my $save_temps = $ENV{SAVE_TEMPS};
85 my $verbose = $ENV{VERBOSE};
87 my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose);