aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/ChangeLog3
-rw-r--r--test/Makefile.am13
-rw-r--r--test/Makefile.in13
-rw-r--r--test/assignconst.awk58
-rw-r--r--test/assignconst.ok42
5 files changed, 125 insertions, 4 deletions
diff --git a/test/ChangeLog b/test/ChangeLog
index 019d2f34..50dcd27c 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -3,6 +3,9 @@
* Makefile.am (fnmatch): New test.
* fnmatch.awk, fnmatch.ok: New files.
+ * Makefile.am (assignconst): New test.
+ * assignconst.awk, assignconst.ok: New files.
+
2012-06-28 Andrew J. Schorr <aschorr@telemetry-investments.com>
* time.awk: Avoid possibly throwing a spurious error by protecting
diff --git a/test/Makefile.am b/test/Makefile.am
index a244c6a0..78fd3117 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -102,6 +102,8 @@ EXTRA_DIST = \
asort.ok \
asorti.awk \
asorti.ok \
+ assignconst.awk \
+ assignconst.ok \
awkpath.ok \
back89.awk \
back89.in \
@@ -891,8 +893,8 @@ LOCALE_CHARSET_TESTS = \
mbprintf1 mbprintf2 mbprintf3 rebt8b2 rtlenmb sort1 sprintfc
SHLIB_TESTS = \
- fnmatch filefuncs fork fork2 ordchr ordchr2 readfile rwarray \
- testext time
+ assignconst fnmatch filefuncs fork fork2 ordchr ordchr2 \
+ readfile rwarray testext time
# List of the tests which should be run with --lint option:
NEED_LINT = \
@@ -1594,6 +1596,13 @@ testext::
@$(AWK) -f testext.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ testext.awk
+assignconst:
+ @echo $@
+ @for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14; \
+ do $(AWK) -f $(srcdir)/$@.awk $$i ; \
+ done 2>&1 | grep -v at_exit > _$@
+ @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@
+
# Targets generated for other tests:
include Maketests
diff --git a/test/Makefile.in b/test/Makefile.in
index 61e32b1b..d12139cf 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -314,6 +314,8 @@ EXTRA_DIST = \
asort.ok \
asorti.awk \
asorti.ok \
+ assignconst.awk \
+ assignconst.ok \
awkpath.ok \
back89.awk \
back89.in \
@@ -1099,8 +1101,8 @@ LOCALE_CHARSET_TESTS = \
mbprintf1 mbprintf2 mbprintf3 rebt8b2 rtlenmb sort1 sprintfc
SHLIB_TESTS = \
- fnmatch filefuncs fork fork2 ordchr ordchr2 readfile rwarray \
- testext time
+ assignconst fnmatch filefuncs fork fork2 ordchr ordchr2 \
+ readfile rwarray testext time
# List of the tests which should be run with --lint option:
@@ -1975,6 +1977,13 @@ testext::
@$(AWK) '/^(@load|BEGIN)/,/^}/' $(top_srcdir)/extension/testext.c > testext.awk
@$(AWK) -f testext.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ testext.awk
+
+assignconst:
+ @echo $@
+ @for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14; \
+ do $(AWK) -f $(srcdir)/$@.awk $$i ; \
+ done 2>&1 | grep -v at_exit > _$@
+ @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@
Gt-dummy:
# file Maketests, generated from Makefile.am by the Gentests program
addcomma:
diff --git a/test/assignconst.awk b/test/assignconst.awk
new file mode 100644
index 00000000..907987c7
--- /dev/null
+++ b/test/assignconst.awk
@@ -0,0 +1,58 @@
+@load "testext"
+
+BEGIN {
+ print ""
+ print "test:", ARGV[1]
+ switch (ARGV[1] + 0) {
+ case 1:
+ answer_num = 43
+ break
+ case 2:
+ ++answer_num
+ break
+ case 3:
+ --answer_num
+ break
+ case 4:
+ answer_num++
+ break
+ case 5:
+ answer_num--
+ break
+ case 6:
+ answer_num += 1
+ break
+ case 7:
+ answer_num -= 1
+ break
+ case 8:
+ answer_num *= 1
+ break
+ case 9:
+ answer_num /= 1
+ break
+ case 10:
+ answer_num ^= 1
+ break
+ case 11:
+ answer_num = answer_num "foo"
+ break
+ case 12:
+ sub(/2/, "3", answer_num)
+ break
+ case 13:
+ a[1] = 1
+ for (answer_num in a)
+ print answer_num, a[answer_num]
+ break
+ case 14:
+ test_func(answer_num)
+ break
+ }
+}
+
+function test_func(val)
+{
+ val++
+ print "in test_func, val now =", val
+}
diff --git a/test/assignconst.ok b/test/assignconst.ok
new file mode 100644
index 00000000..e2bc7494
--- /dev/null
+++ b/test/assignconst.ok
@@ -0,0 +1,42 @@
+
+test: 1
+gawk: ./assignconst.awk:8: fatal: cannot assign to defined constant
+
+test: 2
+gawk: ./assignconst.awk:11: fatal: cannot assign to defined constant
+
+test: 3
+gawk: ./assignconst.awk:14: fatal: cannot assign to defined constant
+
+test: 4
+gawk: ./assignconst.awk:17: fatal: cannot assign to defined constant
+
+test: 5
+gawk: ./assignconst.awk:20: fatal: cannot assign to defined constant
+
+test: 6
+gawk: ./assignconst.awk:23: fatal: cannot assign to defined constant
+
+test: 7
+gawk: ./assignconst.awk:26: fatal: cannot assign to defined constant
+
+test: 8
+gawk: ./assignconst.awk:29: fatal: cannot assign to defined constant
+
+test: 9
+gawk: ./assignconst.awk:32: fatal: cannot assign to defined constant
+
+test: 10
+gawk: ./assignconst.awk:35: fatal: cannot assign to defined constant
+
+test: 11
+gawk: ./assignconst.awk:38: fatal: cannot assign to defined constant
+
+test: 12
+gawk: ./assignconst.awk:41: fatal: cannot assign to defined constant
+
+test: 13
+gawk: ./assignconst.awk:45: fatal: cannot assign to defined constant
+
+test: 14
+in test_func, val now = 43