diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile | 44 | ||||
-rw-r--r-- | test/arrayparm.awk | 21 | ||||
-rw-r--r-- | test/arrayparm.good | 1 | ||||
-rw-r--r-- | test/convfmt.awk | 10 | ||||
-rw-r--r-- | test/convfmt.good | 3 | ||||
-rw-r--r-- | test/nonl.awk | 1 | ||||
-rw-r--r-- | test/nonl.good | 1 | ||||
-rw-r--r-- | test/paramdup.awk | 8 | ||||
-rw-r--r-- | test/paramdup.good | 2 |
9 files changed, 88 insertions, 3 deletions
diff --git a/test/Makefile b/test/Makefile index 0cd4397c..1ad2b2c7 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,10 +1,32 @@ +# Makefile for GNU Awk test suite. +# +# Copyright (C) 1988-1995 the Free Software Foundation, Inc. +# +# This file is part of GAWK, the GNU implementation of the +# AWK Progamming Language. +# +# GAWK is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GAWK is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GAWK; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + SHELL = /bin/sh bigtest: basic poundbang gawk.extensions basic: msg swaplns messages argarray longwrds \ getline fstabplus compare arrayref rs fsrs rand \ - fsbs negexp asgext anchgsub splitargv awkpath nfset reparse + fsbs negexp asgext anchgsub splitargv awkpath nfset reparse \ + convfmt arrayparm paramdup nonl gawk.extensions: fieldwdth ignrcase posix manyfiles igncfs argtest \ badargs @@ -28,7 +50,7 @@ swaplns:: messages:: @../gawk -f messages.awk >out2 2>out3 - { cmp out1.good out1 && cmp out2.good out2 && cmp out3.good out3 && rm -f out1 out2 out3; } || { test -c /dev/stdout && echo IT IS OK THAT THIS TEST FAILED; } + { cmp out1.good out1 && cmp out2.good out2 && cmp out3.good out3 && rm -f out1 out2 out3; } || { test -d /dev/fd && echo IT IS OK THAT THIS TEST FAILED; } argarray:: @TEST=test echo just a test | ../gawk -f argarray.awk argarray.awk - >tmp @@ -139,8 +161,24 @@ argtest:: cmp argtest.good tmp && rm -f tmp badargs:: - @-../gawk -f 2>&1 | grep -v patchlevel > tmp + @-../gawk -f 2>&1 | grep -v patchlevel >tmp cmp badargs.good tmp && rm -f tmp +convfmt:: + @../gawk -f convfmt.awk >tmp + cmp convfmt.good tmp && rm -f tmp + +arrayparm:: + @-../gawk -f arrayparm.awk >tmp 2>&1 + cmp arrayparm.good tmp && rm -f tmp + +paramdup:: + @-../gawk -f paramdup.awk >tmp 2>&1 + cmp paramdup.good tmp && rm -f tmp + +nonl:: + @-../gawk --lint -f nonl.awk /dev/null >tmp 2>&1 + cmp nonl.good tmp && rm -f tmp + clean: rm -fr tmp core junk diff --git a/test/arrayparm.awk b/test/arrayparm.awk new file mode 100644 index 00000000..d6f34d96 --- /dev/null +++ b/test/arrayparm.awk @@ -0,0 +1,21 @@ +# +# Test program from: +# +# Date: Tue, 21 Feb 95 16:09:29 EST +# From: emory!blackhawk.com!aaron (Aaron Sosnick) +# +BEGIN { + foo[1]=1; + foo[2]=2; + bug1(foo); +} +function bug1(i) { + for (i in foo) { + bug2(i); + delete foo[i]; + print i,1,bot[1]; + } +} +function bug2(arg) { + bot[arg]=arg; +} diff --git a/test/arrayparm.good b/test/arrayparm.good new file mode 100644 index 00000000..b315f7cf --- /dev/null +++ b/test/arrayparm.good @@ -0,0 +1 @@ +gawk: arrayparm.awk:18: fatal: attempt to use array `foo' in a scalar context diff --git a/test/convfmt.awk b/test/convfmt.awk new file mode 100644 index 00000000..90fd204b --- /dev/null +++ b/test/convfmt.awk @@ -0,0 +1,10 @@ +BEGIN { + CONVFMT = "%2.2f" + a = 123.456 + b = a "" # give `a' string value also + printf "a = %s\n", a + CONVFMT = "%.6g" + printf "a = %s\n", a + a += 0 # make `a' numeric only again + printf "a = %s\n", a # use `a' as string +} diff --git a/test/convfmt.good b/test/convfmt.good new file mode 100644 index 00000000..a7b66f78 --- /dev/null +++ b/test/convfmt.good @@ -0,0 +1,3 @@ +a = 123.46 +a = 123.456 +a = 123.456 diff --git a/test/nonl.awk b/test/nonl.awk new file mode 100644 index 00000000..c2270834 --- /dev/null +++ b/test/nonl.awk @@ -0,0 +1 @@ +0
\ No newline at end of file diff --git a/test/nonl.good b/test/nonl.good new file mode 100644 index 00000000..24bd9b78 --- /dev/null +++ b/test/nonl.good @@ -0,0 +1 @@ +gawk: nonl.awk:1: warning: source file does not end in newline diff --git a/test/paramdup.awk b/test/paramdup.awk new file mode 100644 index 00000000..1f1cc7a4 --- /dev/null +++ b/test/paramdup.awk @@ -0,0 +1,8 @@ +BEGIN { foo(0, 1, 2) } + +function foo(a, b, c, b, a) +{ + print "a =", a + print "b =", b + print "c =", c +} diff --git a/test/paramdup.good b/test/paramdup.good new file mode 100644 index 00000000..0308cc8c --- /dev/null +++ b/test/paramdup.good @@ -0,0 +1,2 @@ +gawk: paramdup.awk:4: error: function `foo': parameter #4, `b', duplicates parameter #2 +gawk: paramdup.awk:4: error: function `foo': parameter #5, `a', duplicates parameter #1 |