summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2001-08-18 16:13:16 +0000
committerJim Meyering <jim@meyering.net>2001-08-18 16:13:16 +0000
commit7650a9d9e4c0eb5083cc64abeb975c43cd06571b (patch)
treea2994927e3cae60c0ae0044436b5ea3731368095 /tests
parentb87d62b760c14e53c3008611f63f209765d918f6 (diff)
downloadcoreutils-7650a9d9e4c0eb5083cc64abeb975c43cd06571b.tar.xz
*** empty log message ***
Diffstat (limited to 'tests')
-rw-r--r--tests/expr/Makefile.am11
-rwxr-xr-xtests/expr/basic54
2 files changed, 65 insertions, 0 deletions
diff --git a/tests/expr/Makefile.am b/tests/expr/Makefile.am
new file mode 100644
index 000000000..82cb59a62
--- /dev/null
+++ b/tests/expr/Makefile.am
@@ -0,0 +1,11 @@
+## Process this file with automake to produce Makefile.in -*-Makefile-*-.
+AUTOMAKE_OPTIONS = 1.3b gnits
+
+TESTS = basic
+EXTRA_DIST = $(TESTS)
+TESTS_ENVIRONMENT = \
+ top_srcdir=$(top_srcdir) \
+ srcdir=$(srcdir) \
+ PERL="@PERL@" \
+ PATH=`pwd`/../../src:$$PATH \
+ PROG=expr
diff --git a/tests/expr/basic b/tests/expr/basic
new file mode 100755
index 000000000..812422e3d
--- /dev/null
+++ b/tests/expr/basic
@@ -0,0 +1,54 @@
+#!/bin/sh
+# -*-perl-*-
+
+: ${PERL=perl}
+: ${srcdir=.}
+
+case "$PERL" in
+ *'missing perl')
+ echo 1>&2 "$0: configure didn't find a usable version of Perl," \
+ "so can't run this test"
+ exit 77
+ ;;
+esac
+
+d=$srcdir/..
+exec $PERL -w -I$d -MFetish -- - << \EOF
+require 5.003;
+use strict;
+
+(my $program_name = $0) =~ s|.*/||;
+
+# Turn off localisation of executable's ouput.
+@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
+
+my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n";
+
+my @Tests =
+ (
+ ['invalid-a', '3 + -', {ERR => "$prog: non-numeric argument\n"},
+ {EXIT => 1}],
+
+ ['a', '5 + 6', {OUT => '11'}],
+ );
+
+# Prepend the command line argument and append a newline to end
+# of each expected `OUT' string.
+my $t;
+foreach $t (@Tests)
+ {
+ my $arg1 = $t->[1];
+ my $e;
+ foreach $e (@$t)
+ {
+ $e->{OUT} = "$arg1: $e->{OUT}\n"
+ if ref $e eq 'HASH' and exists $e->{OUT};
+ }
+ }
+
+my $save_temps = $ENV{SAVE_TEMPS};
+my $verbose = $ENV{VERBOSE};
+
+my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose);
+exit $fail;
+EOF