aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/ChangeLog17
-rw-r--r--test/Makefile.am22
-rw-r--r--test/Makefile.in22
-rw-r--r--test/readall.ok7
-rw-r--r--test/readall1.awk10
-rw-r--r--test/readall2.awk15
-rw-r--r--test/testext-mpfr.ok2
-rw-r--r--test/testext.ok2
8 files changed, 91 insertions, 6 deletions
diff --git a/test/ChangeLog b/test/ChangeLog
index 034cc63b..c6c0c657 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,20 @@
+2021-12-08 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * Makefile.am (EXTRA_DIST): Add readall1.awk, readall2.awk, and
+ readall.ok.
+ (SHLIB_TESTS): Add readall.
+ (GENTESTS_UNUSED): Add readall1.awk and readall2.awk.
+ (readall): Add new test of the writeall and readall functions.
+ * readall1.awk, readall2.awk, readall.ok: New files.
+
+2021-12-08 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * Makefile.am (testext): Change awk pattern to include functions in
+ testext.awk.
+ (diffout): If running MPFR tests and there's an mpfr.ok file, compare
+ to that instead of to the regular ok file.
+ * testext.ok, testext-mpfr.ok: Update for new test_array_create test.
+
2021-12-07 Andrew J. Schorr <aschorr@telemetry-investments.com>
* iolint.awk, iolint.ok: Reorder "cat" pipe/output file test to reduce
diff --git a/test/Makefile.am b/test/Makefile.am
index 10c5c812..1fa8ad3f 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1031,6 +1031,9 @@ EXTRA_DIST = \
range1.ok \
range2.awk \
range2.ok \
+ readall1.awk \
+ readall2.awk \
+ readall.ok \
readbuf.awk \
readbuf.ok \
readdir.awk \
@@ -1490,6 +1493,7 @@ SHLIB_TESTS = \
getfile \
inplace1 inplace2 inplace2bcomp inplace3 inplace3bcomp \
ordchr ordchr2 \
+ readall \
readdir readdir_test readdir_retest readfile readfile2 revout \
revtwoway rwarray \
testext time
@@ -1597,7 +1601,8 @@ ZOS_FAIL = @ZOS_FAIL@
GENTESTS_UNUSED = Makefile.in checknegtime.awk dtdgport.awk fix-fmtspcl.awk \
fmtspcl-mpfr.ok fmtspcl.awk fmtspcl.tok gtlnbufv.awk hello.awk \
inchello.awk inclib.awk inplace.1.in inplace.2.in inplace.in \
- printfloat.awk readdir0.awk valgrind.awk xref.awk
+ printfloat.awk readdir0.awk valgrind.awk xref.awk \
+ readall1.awk readall2.awk
# List of tests on MinGW or DJGPP that need a different cmp program
NEED_TESTOUTCMP = \
@@ -2281,7 +2286,7 @@ inplace3bcomp::
testext::
@echo $@
- @-$(AWK) ' /^(@load|BEGIN)/,/^}/' "$(top_srcdir)"/extension/testext.c > testext.awk
+ @-$(AWK) ' /^(@load|BEGIN|function)/,/^}/' "$(top_srcdir)"/extension/testext.c > testext.awk
@-$(AWK) -f ./testext.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-if echo "$$GAWK_TEST_ARGS" | egrep -e '-M|--bignum' > /dev/null; \
then $(CMP) "$(srcdir)"/$@-mpfr.ok _$@ && rm -f _$@ testext.awk testexttmp.txt ; \
@@ -2317,6 +2322,13 @@ readdir_retest:
@-$(AWK) -lreaddir_test -F/ -f "$(srcdir)"/$@.awk "$(top_srcdir)" > _$@
@-$(CMP) $@.ok _$@ && rm -f $@.ok _$@
+readall:
+ @echo $@
+ @-$(AWK) -lrwarray -f "$(srcdir)"/$@1.awk -v "ofile=readall.state" > _$@
+ @-$(AWK) -lrwarray -f "$(srcdir)"/$@2.awk -v "ifile=readall.state" >> _$@
+ @-$(CMP) $@.ok _$@ && rm -f _$@
+ @-$(RM) -f readall.state
+
fts:
@echo $@
@-case `uname` in \
@@ -2518,7 +2530,11 @@ diffout:
if [ "$$i" != "_*" ]; then \
echo ============== $$i ============= ; \
base=`echo $$i | sed 's/^_//'` ; \
- if [ -r $${base}.ok ]; then \
+ if echo "$$GAWK_TEST_ARGS" | egrep -e '-M|--bignum' > /dev/null && [ -r $${base}-mpfr.ok ]; then \
+ diff -u $${base}-mpfr.ok $$i ; \
+ elif echo "$$GAWK_TEST_ARGS" | egrep -e '-M|--bignum' > /dev/null && [ -r "$(srcdir)"/$${base}-mpfr.ok ]; then \
+ diff -u "$(srcdir)"/$${base}-mpfr.ok $$i ; \
+ elif [ -r $${base}.ok ]; then \
diff -u $${base}.ok $$i ; \
else \
diff -u "$(srcdir)"/$${base}.ok $$i ; \
diff --git a/test/Makefile.in b/test/Makefile.in
index 6144e749..c6c131fc 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -1297,6 +1297,9 @@ EXTRA_DIST = \
range1.ok \
range2.awk \
range2.ok \
+ readall1.awk \
+ readall2.awk \
+ readall.ok \
readbuf.awk \
readbuf.ok \
readdir.awk \
@@ -1752,6 +1755,7 @@ SHLIB_TESTS = \
getfile \
inplace1 inplace2 inplace2bcomp inplace3 inplace3bcomp \
ordchr ordchr2 \
+ readall \
readdir readdir_test readdir_retest readfile readfile2 revout \
revtwoway rwarray \
testext time
@@ -1864,7 +1868,8 @@ EXPECTED_FAIL_ZOS = \
GENTESTS_UNUSED = Makefile.in checknegtime.awk dtdgport.awk fix-fmtspcl.awk \
fmtspcl-mpfr.ok fmtspcl.awk fmtspcl.tok gtlnbufv.awk hello.awk \
inchello.awk inclib.awk inplace.1.in inplace.2.in inplace.in \
- printfloat.awk readdir0.awk valgrind.awk xref.awk
+ printfloat.awk readdir0.awk valgrind.awk xref.awk \
+ readall1.awk readall2.awk
# List of tests on MinGW or DJGPP that need a different cmp program
@@ -2735,7 +2740,7 @@ inplace3bcomp::
testext::
@echo $@
- @-$(AWK) ' /^(@load|BEGIN)/,/^}/' "$(top_srcdir)"/extension/testext.c > testext.awk
+ @-$(AWK) ' /^(@load|BEGIN|function)/,/^}/' "$(top_srcdir)"/extension/testext.c > testext.awk
@-$(AWK) -f ./testext.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-if echo "$$GAWK_TEST_ARGS" | egrep -e '-M|--bignum' > /dev/null; \
then $(CMP) "$(srcdir)"/$@-mpfr.ok _$@ && rm -f _$@ testext.awk testexttmp.txt ; \
@@ -2771,6 +2776,13 @@ readdir_retest:
@-$(AWK) -lreaddir_test -F/ -f "$(srcdir)"/$@.awk "$(top_srcdir)" > _$@
@-$(CMP) $@.ok _$@ && rm -f $@.ok _$@
+readall:
+ @echo $@
+ @-$(AWK) -lrwarray -f "$(srcdir)"/$@1.awk -v "ofile=readall.state" > _$@
+ @-$(AWK) -lrwarray -f "$(srcdir)"/$@2.awk -v "ifile=readall.state" >> _$@
+ @-$(CMP) $@.ok _$@ && rm -f _$@
+ @-$(RM) -f readall.state
+
fts:
@echo $@
@-case `uname` in \
@@ -5345,7 +5357,11 @@ diffout:
if [ "$$i" != "_*" ]; then \
echo ============== $$i ============= ; \
base=`echo $$i | sed 's/^_//'` ; \
- if [ -r $${base}.ok ]; then \
+ if echo "$$GAWK_TEST_ARGS" | egrep -e '-M|--bignum' > /dev/null && [ -r $${base}-mpfr.ok ]; then \
+ diff -u $${base}-mpfr.ok $$i ; \
+ elif echo "$$GAWK_TEST_ARGS" | egrep -e '-M|--bignum' > /dev/null && [ -r "$(srcdir)"/$${base}-mpfr.ok ]; then \
+ diff -u "$(srcdir)"/$${base}-mpfr.ok $$i ; \
+ elif [ -r $${base}.ok ]; then \
diff -u $${base}.ok $$i ; \
else \
diff -u "$(srcdir)"/$${base}.ok $$i ; \
diff --git a/test/readall.ok b/test/readall.ok
new file mode 100644
index 00000000..b343af59
--- /dev/null
+++ b/test/readall.ok
@@ -0,0 +1,7 @@
+1
+1
+5.9 3 -2.327
+zebra[archie] = banana
+zebra[0] = apple
+zebra[3][foo] = bar
+zebra[3][bar] = foo
diff --git a/test/readall1.awk b/test/readall1.awk
new file mode 100644
index 00000000..2888d157
--- /dev/null
+++ b/test/readall1.awk
@@ -0,0 +1,10 @@
+BEGIN {
+ x = 5.9
+ y = 3
+ z = -2.327
+ zebra[0] = "apple"
+ zebra["archie"] = "banana"
+ zebra[3]["foo"] = "bar"
+ zebra[3]["bar"] = "foo"
+ print writeall(ofile)
+}
diff --git a/test/readall2.awk b/test/readall2.awk
new file mode 100644
index 00000000..8b79849a
--- /dev/null
+++ b/test/readall2.awk
@@ -0,0 +1,15 @@
+function printarray(n, x, i) {
+ for (i in x) {
+ if (isarray(x[i]))
+ printarray((n "[" i "]"), x[i])
+ else
+ printf "%s[%s] = %s\n", n, i, x[i]
+ }
+}
+
+BEGIN {
+ print readall(ifile)
+ print x, y, z
+ #print zebra[0], zebra[3]["foo"], zebra[3]["bar"]
+ printarray("zebra", zebra)
+}
diff --git a/test/testext-mpfr.ok b/test/testext-mpfr.ok
index 2c616c67..ec584216 100644
--- a/test/testext-mpfr.ok
+++ b/test/testext-mpfr.ok
@@ -48,6 +48,8 @@ test_array_param: argument is not undefined (1)
test_array_param() returned 0
isarray(a_scalar) = 0
+test_array_create returned 1
+good: we have an array
Initial value of LINT is 0
print_do_lint: lint = 0
print_do_lint() returned 1
diff --git a/test/testext.ok b/test/testext.ok
index fbc3c263..1d058302 100644
--- a/test/testext.ok
+++ b/test/testext.ok
@@ -48,6 +48,8 @@ test_array_param: argument is not undefined (1)
test_array_param() returned 0
isarray(a_scalar) = 0
+test_array_create returned 1
+good: we have an array
Initial value of LINT is 0
print_do_lint: lint = 0
print_do_lint() returned 1