Tizen 2.0 Release
[external/tizen-coreutils.git] / tests / misc / paste-no-nl
1 #!/bin/sh
2 # -*- perl -*-
3 # Ensure that paste properly handles files lacking a final newline.
4
5 # Copyright (C) 2003, 2005 Free Software Foundation, Inc.
6
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.
11
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.
16
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
20 # 02110-1301, USA.
21
22 : ${PERL=perl}
23 : ${srcdir=.}
24
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"
28   exit 77
29 }
30
31 exec $PERL -w -I$srcdir/.. -MCoreutils -- - <<\EOF
32 #/
33 require 5.003;
34 use strict;
35
36 (my $program_name = $0) =~ s|.*/||;
37
38 $ENV{PROG} = 'paste';
39
40 # Turn off localization of executable's ouput.
41 @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
42
43 my @Tests =
44   (
45    ['no-nl-1', {IN=>"a"},   {IN=>"b"},   {OUT=>"a\tb\n"}],
46    ['no-nl-2', {IN=>"a\n"}, {IN=>"b"},   {OUT=>"a\tb\n"}],
47    ['no-nl-3', {IN=>"a"},   {IN=>"b\n"}, {OUT=>"a\tb\n"}],
48    ['no-nl-4', {IN=>"a\n"}, {IN=>"b\n"}, {OUT=>"a\tb\n"}],
49
50    # Same as above, but with a two lines in each input file and
51    # the addition of the -d option to make SPACE be the output delimiter.
52    ['no-nla1', '-d" "', {IN=>"1\na"},   {IN=>"2\nb"},   {OUT=>"1 2\na b\n"}],
53    ['no-nla2', '-d" "', {IN=>"1\na\n"}, {IN=>"2\nb"},   {OUT=>"1 2\na b\n"}],
54    ['no-nla3', '-d" "', {IN=>"1\na"},   {IN=>"2\nb\n"}, {OUT=>"1 2\na b\n"}],
55    ['no-nla4', '-d" "', {IN=>"1\na\n"}, {IN=>"2\nb\n"}, {OUT=>"1 2\na b\n"}],
56   );
57
58 my $save_temps = $ENV{DEBUG};
59 my $verbose = $ENV{VERBOSE};
60
61 my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n";
62 my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose);
63 exit $fail;
64 EOF