*** empty log message ***
[coreutils.git] / tests / seq / basic
blob93b2ff03e4d7cb4c8fde9031697dd639e1d6637e
1 #!/bin/sh
2 # -*- perl -*-
4 : ${PERL=perl}
5 : ${srcdir=.}
7 $PERL -e 1 > /dev/null 2>&1 || {
8 echo 1>&2 "$0: configure didn't find a usable version of Perl," \
9 "so can't run this test"
10 exit 77
13 d=$srcdir/..
14 exec $PERL -w -I$d -MFetish -- - << \EOF
15 require 5.003;
16 use strict;
18 (my $program_name = $0) =~ s|.*/||;
20 # Turn off localisation of executable's ouput.
21 @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
23 my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n";
25 my @Tests =
27 ['onearg-1', qw(10), {OUT => [(1..10)]}],
28 ['onearg-2', qw(-1)],
29 ['neg-1', qw(-10 10 10), {OUT => [qw(-10 0 10)]}],
30 ['neg-2', qw(-.1 .1 .1), {OUT => [qw(-0.1 0 0.1)]}],
31 ['neg-3', qw(1 -1 0), {OUT => [qw(1 0)]}],
32 ['neg-4', qw(1 -1 -1), {OUT => [qw(1 0 -1)]}],
34 ['eq-wid-1', qw(-w 1 -1 -1), {OUT => [qw(01 00 -1)]}],
36 # Prior to 2.0g, this test would fail on e.g., HPUX systems
37 # because it'd end up using %3.1f as the format instead of %4.1f.
38 ['eq-wid-2', qw(-w -.1 .1 .1),{OUT => [qw(-0.1 00.0 00.1)]}],
40 # Prior to coreutils-4.5.11, some of these were not accepted.
41 ['fmt-1', qw(-f %2.1f 1.5 .5 2),{OUT => [qw(1.5 2.0)]}],
42 ['fmt-2', qw(-f %0.1f 1.5 .5 2),{OUT => [qw(1.5 2.0)]}],
43 ['fmt-3', qw(-f %.1f 1.5 .5 2),{OUT => [qw(1.5 2.0)]}],
45 ['fmt-4', qw(-f %3.0f 1 2), {OUT => [' 1', ' 2']}],
46 ['fmt-5', qw(-f %-3.0f 1 2), {OUT => ['1 ', '2 ']}],
47 ['fmt-6', qw(-f %+3.0f 1 2), {OUT => [' +1', ' +2']}],
48 ['fmt-7', qw(-f %0+3.0f 1 2), {OUT => [qw(+01 +02)]}],
49 ['fmt-8', qw(-f %0+.0f 1 2), {OUT => [qw(+1 +2)]}],
50 ['fmt-9', '-f "% -3.0f"', qw(-1 0), {OUT => ['-1 ', ' 0 ']}],
51 ['fmt-a', '-f "% -.0f"',qw(-1 0), {OUT => ['-1', ' 0']}],
54 # Append a newline to each entry in the OUT array.
55 my $t;
56 foreach $t (@Tests)
58 my $e;
59 foreach $e (@$t)
61 $e->{OUT} = join ("\n", @{$e->{OUT}}) . "\n"
62 if ref $e eq 'HASH' and exists $e->{OUT};
66 my $save_temps = $ENV{SAVE_TEMPS};
67 my $verbose = $ENV{VERBOSE};
69 my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose);
70 exit $fail;
71 EOF