aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test/ChangeLog5
-rw-r--r--test/Makefile.am18
-rw-r--r--test/Makefile.in18
-rw-r--r--test/exit.ok25
-rwxr-xr-xtest/exit.sh57
-rw-r--r--test/next.ok4
-rwxr-xr-xtest/next.sh20
7 files changed, 145 insertions, 2 deletions
diff --git a/test/ChangeLog b/test/ChangeLog
index 7b3aa52a..c429ce4c 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,8 @@
+Wed Mar 30 22:00:59 2011 Arnold D. Robbins <arnold@skeeve.com>
+
+ * next.sh, exit.sh: New files from John Haque, edited somewhat.
+ * Makefile.am (next, exit): New tests.
+
Mon Feb 21 20:32:36 2011 Arnold D. Robbins <arnold@skeeve.com>
* Makefile.am (GAWK_EXT_TESTS): Include profile3. Thanks to
diff --git a/test/Makefile.am b/test/Makefile.am
index a63c15c3..2fecaca0 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -172,6 +172,8 @@ EXTRA_DIST = \
dynlj.ok \
eofsplit.awk \
eofsplit.ok \
+ exit.ok \
+ exit.sh \
exitval1.awk \
exitval1.ok \
exitval2.awk \
@@ -414,6 +416,8 @@ EXTRA_DIST = \
nested.awk \
nested.in \
nested.ok \
+ next.ok \
+ next.sh \
nfldstr.awk \
nfldstr.in \
nfldstr.ok \
@@ -736,13 +740,15 @@ BASIC_TESTS = addcomma anchgsub argarray arrayparm arrayprm2 arrayprm3 \
aryprm8 arysubnm asgext awkpath back89 backgsub childin clobber \
closebad clsflnam compare compare2 concat1 concat2 concat3 concat4 \
convfmt datanonl defref delarpm2 delarprm delfunc dynlj eofsplit \
+ exit \
exitval1 exitval2 fcall_exit fcall_exit2 fldchg fldchgnf fnamedat \
fnarray fnarray2 fnaryscl fnasgnm fnmisc fordel forref forsimp \
fsbs fsrs fsspcoln fstabplus funsemnl funsmnam funstack getline \
getline2 getline3 getlnbuf getnr2tb getnr2tm gsubasgn gsubtest gsubtst2 \
gsubtst3 gsubtst4 gsubtst5 gsubtst6 hex hsprint inputred intest intprec iobug1 \
leaddig leadnl litoct longsub longwrds manglprm math membug1 messages \
- minusstr mmap8k mtchi18n nasty nasty2 negexp negrange nested nfldstr nfneg \
+ minusstr mmap8k mtchi18n nasty nasty2 negexp negrange nested next \
+ nfldstr nfneg \
nfset nlfldsep nlinstr nlstrina noeffect nofile nofmtch noloop1 \
noloop2 nonl noparms nors nulrsend numindex numsubstr octsub ofmt \
ofmtbig ofmtfidl ofmts onlynl opasnidx opasnslf paramdup paramres \
@@ -1334,6 +1340,16 @@ profile3:
@sed 1,2d < awkprof.out > _$@; rm awkprof.out
@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@
+next:
+ @echo $@
+ @-AWK="$(AWKPROG)" $(srcdir)/$@.sh > _$@ 2>&1
+ @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@
+
+exit:
+ @echo $@
+ @-AWK="$(AWKPROG)" $(srcdir)/$@.sh > _$@ 2>&1
+ @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@
+
# Targets generated for other tests:
include Maketests
diff --git a/test/Makefile.in b/test/Makefile.in
index a6783c83..51bdf298 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -357,6 +357,8 @@ EXTRA_DIST = \
dynlj.ok \
eofsplit.awk \
eofsplit.ok \
+ exit.ok \
+ exit.sh \
exitval1.awk \
exitval1.ok \
exitval2.awk \
@@ -599,6 +601,8 @@ EXTRA_DIST = \
nested.awk \
nested.in \
nested.ok \
+ next.ok \
+ next.sh \
nfldstr.awk \
nfldstr.in \
nfldstr.ok \
@@ -921,13 +925,15 @@ BASIC_TESTS = addcomma anchgsub argarray arrayparm arrayprm2 arrayprm3 \
aryprm8 arysubnm asgext awkpath back89 backgsub childin clobber \
closebad clsflnam compare compare2 concat1 concat2 concat3 concat4 \
convfmt datanonl defref delarpm2 delarprm delfunc dynlj eofsplit \
+ exit \
exitval1 exitval2 fcall_exit fcall_exit2 fldchg fldchgnf fnamedat \
fnarray fnarray2 fnaryscl fnasgnm fnmisc fordel forref forsimp \
fsbs fsrs fsspcoln fstabplus funsemnl funsmnam funstack getline \
getline2 getline3 getlnbuf getnr2tb getnr2tm gsubasgn gsubtest gsubtst2 \
gsubtst3 gsubtst4 gsubtst5 gsubtst6 hex hsprint inputred intest intprec iobug1 \
leaddig leadnl litoct longsub longwrds manglprm math membug1 messages \
- minusstr mmap8k mtchi18n nasty nasty2 negexp negrange nested nfldstr nfneg \
+ minusstr mmap8k mtchi18n nasty nasty2 negexp negrange nested next \
+ nfldstr nfneg \
nfset nlfldsep nlinstr nlstrina noeffect nofile nofmtch noloop1 \
noloop2 nonl noparms nors nulrsend numindex numsubstr octsub ofmt \
ofmtbig ofmtfidl ofmts onlynl opasnidx opasnslf paramdup paramres \
@@ -1682,6 +1688,16 @@ profile3:
@$(PGAWK) -f $(srcdir)/$@.awk > /dev/null
@sed 1,2d < awkprof.out > _$@; rm awkprof.out
@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@
+
+next:
+ @echo $@
+ @-AWK="$(AWKPROG)" $(srcdir)/$@.sh > _$@ 2>&1
+ @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@
+
+exit:
+ @echo $@
+ @-AWK="$(AWKPROG)" $(srcdir)/$@.sh > _$@ 2>&1
+ @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@
Gt-dummy:
# file Maketests, generated from Makefile.am by the Gentests program
addcomma:
diff --git a/test/exit.ok b/test/exit.ok
new file mode 100644
index 00000000..724b4493
--- /dev/null
+++ b/test/exit.ok
@@ -0,0 +1,25 @@
+1
+3
+-- 1
+2
+-- 2
+2
+-- 3
+2
+2
+-- 4
+0
+-- 5
+1 null
+-- 6
+1 null
+-- 7
+0 exit.sh
+-- 8
+1
+0 exit.sh
+-- 9
+0 null
+-- 10
+1 null
+-- 11
diff --git a/test/exit.sh b/test/exit.sh
new file mode 100755
index 00000000..8106fbb4
--- /dev/null
+++ b/test/exit.sh
@@ -0,0 +1,57 @@
+#!/bin/sh
+
+# exit.sh --- text exit invoked in various ways
+
+if [ "$AWK" = "" ]
+then
+ echo $0: You must set AWK >&2
+ exit 1
+fi
+
+# Use awk to print the string instead of echo or printf.
+
+x='BEGIN{print 1; exit; print 2}; NR>1{print}; END{print 3; exit; print 4}'
+$AWK 'BEGIN { print "a\nb" }' | $AWK "$x"
+echo "-- 1"
+
+x='function f(){ exit}; END{print NR;f();print NR}'
+$AWK 'BEGIN { print "a\nb" }' | $AWK "$x"
+echo "-- 2"
+
+x='function f(){ exit}; NR>1 {f()}; END{print NR; f();print NR}'
+$AWK 'BEGIN { print "a\nb" }' | $AWK "$x"
+echo "-- 3"
+
+x='function f(){ exit}; NR>1{ f()}; END{print NR;print NR}'
+$AWK 'BEGIN { print "a\nb" }' | $AWK "$x"
+echo "-- 4"
+
+x='function f(){ exit}; BEGINFILE {f()}; NR>1{ f()}; END{print NR}'
+$AWK 'BEGIN { print "a\nb" }' | $AWK "$x"
+echo "-- 5"
+
+y='function strip(f) { sub(/.*\//, "", f); return f };'
+
+x='BEGINFILE{if(++i==1) exit;}; END{print i, strip(FILENAME)}'
+$AWK "$y$x" /dev/null $0
+echo "-- 6"
+
+x='BEGINFILE{if(++i==1) exit;}; ENDFILE{print i++}; END{print i, strip(FILENAME)}'
+$AWK "$y$x" /dev/null $0
+echo "-- 7"
+
+x='function f(){ exit}; BEGINFILE{i++ && f()}; END{print NR,strip(FILENAME)}'
+$AWK "$y$x" /dev/null $0
+echo "-- 8"
+
+x='function f(){ exit}; BEGINFILE{i++ && f()}; ENDFILE{ print i}; END{print NR,strip(FILENAME)}'
+$AWK "$y$x" /dev/null $0
+echo "-- 9"
+
+x='function f(){ exit}; BEGINFILE{i++}; ENDFILE{ f(); print i}; END{print NR,strip(FILENAME)}'
+$AWK "$y$x" /dev/null $0
+echo "-- 10"
+
+x='function f(){ exit}; BEGINFILE{i++}; ENDFILE{ i>1 && f(); print i, strip(FILENAME)}'
+$AWK "$y$x" /dev/null $0
+echo "-- 11"
diff --git a/test/next.ok b/test/next.ok
new file mode 100644
index 00000000..0229bd0a
--- /dev/null
+++ b/test/next.ok
@@ -0,0 +1,4 @@
+gawk: cmd. line:1: fatal: `next' cannot be called from a `BEGIN' rule
+gawk: cmd. line:1: fatal: `next' cannot be called from a `END' rule
+gawk: cmd. line:1: fatal: `next' cannot be called from a `BEGINFILE' rule
+gawk: cmd. line:1: fatal: `next' cannot be called from a `ENDFILE' rule
diff --git a/test/next.sh b/test/next.sh
new file mode 100755
index 00000000..77354a25
--- /dev/null
+++ b/test/next.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+# next.sh --- test next invoked in various ways
+
+if [ "$AWK" = "" ]
+then
+ echo $0: You must set AWK >&2
+ exit 1
+fi
+
+# non-fatal
+$AWK '{next}' /dev/null
+$AWK 'function f() { next}; {f()}' /dev/null
+# fatal
+$AWK 'function f() { next}; BEGIN{f()}'
+$AWK 'function f() { next}; {f()}; END{f()}' /dev/null
+$AWK 'function f() { next}; BEGINFILE{f()}'
+$AWK 'function f() { next}; {f()}; ENDFILE{f()}' /dev/null
+
+exit 0 # for make