aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Makefile27
-rw-r--r--test/argarray.awk2
-rw-r--r--test/argarray.good2
-rw-r--r--test/argtest.awk4
-rw-r--r--test/argtest.good4
-rw-r--r--test/badargs.good17
6 files changed, 46 insertions, 10 deletions
diff --git a/test/Makefile b/test/Makefile
index cbe054fd..72027a9b 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -6,7 +6,8 @@ basic: msg swaplns messages argarray longwrds \
getline fstabplus compare arrayref rs fsrs rand \
fsbs negexp asgext anchgsub splitargv awkpath nfset reparse
-gawk.extensions: fieldwdth ignrcase posix manyfiles igncfs
+gawk.extensions: fieldwdth ignrcase posix manyfiles igncfs argtest \
+ badargtest
extra: regtest inftest
@@ -27,8 +28,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
+ cmp out1.good out1 && cmp out2.good out2 && cmp out3.good out3 && rm -f out1 out2 out3
argarray::
@TEST=test ../gawk -f argarray.awk >tmp
@@ -51,11 +51,11 @@ longwrds::
cmp longwrds.good tmp && rm -f tmp
fieldwdth::
- @echo '123456789' | ../gawk -v FIELDWIDTHS="2 3 4" '{print $$2}' >tmp
+ @echo '123456789' | ../gawk -v FIELDWIDTHS="2 3 4" '{ print $$2}' >tmp
cmp fieldwdth.good tmp && rm -f tmp
ignrcase::
- @echo xYz | ../gawk -v IGNORECASE=1 '{sub(/y/, ""); print}' >tmp
+ @echo xYz | ../gawk -v IGNORECASE=1 '{ sub(/y/, ""); print}' >tmp
cmp ignrcase.good tmp && rm -f tmp
regtest::
@@ -72,7 +72,7 @@ manyfiles::
@mkdir junk
@../gawk 'BEGIN { for (i = 1; i <= 100; i++) print i, i}' >tmp
@../gawk -f manyfiles.awk tmp tmp
- @echo -n "This number better be 1 ->"
+ @echo "This number better be 1 ->" | tr -d '\012'
@wc -l junk/* | ../gawk '$$1 != 2' | wc -l
@rm -rf junk tmp
@@ -85,7 +85,7 @@ arrayref::
cmp arrayref.good tmp && rm -f tmp
rs::
- @../gawk -v RS="" '{print $$1, $$2}' rs.data >tmp
+ @../gawk -v RS="" '{ print $$1, $$2}' rs.data >tmp
cmp rs.good tmp && rm -f tmp
fsbs::
@@ -106,7 +106,7 @@ rand::
@../gawk -f rand.awk
negexp::
- @../gawk 'BEGIN {a = -2; print 10^a }' >tmp
+ @../gawk 'BEGIN { a = -2; print 10^a }' >tmp
cmp negexp.good tmp && rm -f tmp
asgext::
@@ -132,3 +132,14 @@ nfset::
reparse::
@../gawk -f reparse.awk reparse.in >tmp
cmp reparse.good tmp && rm -f tmp
+
+argtest::
+ @../gawk -f argtest.awk -x -y abc >tmp
+ cmp argtest.good tmp && rm -f tmp
+
+badargtest::
+ @-../gawk -f > tmp 2>&1
+ cmp badargs.good tmp && rm -f tmp
+
+clean:
+ rm -f tmp
diff --git a/test/argarray.awk b/test/argarray.awk
index 3911b6e9..8015d852 100644
--- a/test/argarray.awk
+++ b/test/argarray.awk
@@ -6,6 +6,6 @@ BEGIN {
for (x = 0; x < ARGC; x++)
print "\t", ARGV[x]
print "Environment variable TEST=" ENVIRON["TEST"]
- print "and the current input file is called", FILENAME
+ print "and the current input file is called \"" FILENAME "\""
print "but this would change if we would have something to process"
}
diff --git a/test/argarray.good b/test/argarray.good
index fe6d0bf8..ea16ad72 100644
--- a/test/argarray.good
+++ b/test/argarray.good
@@ -2,5 +2,5 @@ here we have 1 argument
which is
gawk
Environment variable TEST=test
-and the current input file is called -
+and the current input file is called ""
but this would change if we would have something to process
diff --git a/test/argtest.awk b/test/argtest.awk
new file mode 100644
index 00000000..e7a1145d
--- /dev/null
+++ b/test/argtest.awk
@@ -0,0 +1,4 @@
+BEGIN {
+ for (i = 0; i < ARGC; i++)
+ printf("ARGV[%d] = %s\n", i, ARGV[i])
+}
diff --git a/test/argtest.good b/test/argtest.good
new file mode 100644
index 00000000..591bc641
--- /dev/null
+++ b/test/argtest.good
@@ -0,0 +1,4 @@
+ARGV[0] = gawk
+ARGV[1] = -x
+ARGV[2] = -y
+ARGV[3] = abc
diff --git a/test/badargs.good b/test/badargs.good
new file mode 100644
index 00000000..8fffe174
--- /dev/null
+++ b/test/badargs.good
@@ -0,0 +1,17 @@
+gawk: option requires an argument -- f
+Gnu Awk (gawk) 2.15, patchlevel 3
+Usage: gawk [POSIX or GNU style options] -f progfile [--] file ...
+ gawk [POSIX or GNU style options] [--] 'program' file ...
+POSIX options: GNU long options:
+ -f progfile --file=progfile
+ -F fs --field-separator=fs
+ -v var=val --assign=var=val
+ -W compat --compat
+ -W copyleft --copyleft
+ -W copyright --copyright
+ -W help --help
+ -W lint --lint
+ -W posix --posix
+ -W source=program-text --source=program-text
+ -W usage --usage
+ -W version --version