aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/ChangeLog5
-rw-r--r--test/Makefile.am4
-rw-r--r--test/Makefile.in4
-rw-r--r--test/typeof3.awk19
-rw-r--r--test/typeof3.ok8
-rw-r--r--test/typeof4.awk13
-rw-r--r--test/typeof4.ok1
7 files changed, 54 insertions, 0 deletions
diff --git a/test/ChangeLog b/test/ChangeLog
index 393f38e8..8d74c4ef 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,8 @@
+2015-06-25 Arnold D. Robbins <arnold@skeeve.com>
+
+ * Makefile.am (typeof3, typeof4): New tests.
+ * typeof2.awk, typeof2.ok, typeof3.awk, typeof3.ok: New files.
+
2015-06-21 Arnold D. Robbins <arnold@skeeve.com>
* Makefile.am (typeof2): New test.
diff --git a/test/Makefile.am b/test/Makefile.am
index 25b8b708..0c32fa6c 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -987,6 +987,10 @@ EXTRA_DIST = \
typeof1.ok \
typeof2.awk \
typeof2.ok \
+ typeof3.awk \
+ typeof3.ok \
+ typeof4.awk \
+ typeof4.ok \
uninit2.awk \
uninit2.ok \
uninit3.awk \
diff --git a/test/Makefile.in b/test/Makefile.in
index 1ab60181..81562779 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -1244,6 +1244,10 @@ EXTRA_DIST = \
typeof1.ok \
typeof2.awk \
typeof2.ok \
+ typeof3.awk \
+ typeof3.ok \
+ typeof4.awk \
+ typeof4.ok \
uninit2.awk \
uninit2.ok \
uninit3.awk \
diff --git a/test/typeof3.awk b/test/typeof3.awk
new file mode 100644
index 00000000..d148f373
--- /dev/null
+++ b/test/typeof3.awk
@@ -0,0 +1,19 @@
+BEGIN {
+ x = @/xx/
+ print typeof(x)
+ print x
+}
+
+# this set may not really be needed for the test
+BEGIN {
+ x = 4
+ print typeof(@/xxx/)
+ print typeof(3)
+ print x
+}
+
+BEGIN {
+ print typeof(x)
+ print typeof(a[1])
+ a[1][2] # fatals on this
+}
diff --git a/test/typeof3.ok b/test/typeof3.ok
new file mode 100644
index 00000000..c8f458a1
--- /dev/null
+++ b/test/typeof3.ok
@@ -0,0 +1,8 @@
+regexp
+xx
+regexp
+scalar_n
+4
+scalar_n
+untyped
+gawk: test/typeof3.awk:18: fatal: attempt to use scalar `a["1"]' as an array
diff --git a/test/typeof4.awk b/test/typeof4.awk
new file mode 100644
index 00000000..62c2905c
--- /dev/null
+++ b/test/typeof4.awk
@@ -0,0 +1,13 @@
+BEGIN{ a["x"]["y"]["z"]="scalar" ; walk_array(a, "a")}
+function walk_array(arr, name, i, r)
+{
+ for (i in arr) {
+ r = typeof(arr[i])
+# printf("typeof(%s[%s]) = %s\n", name, i, r) > "/dev/stderr"
+ if (r == "array") {
+ walk_array(arr[i], name "[" i "]")
+ } else {
+ printf "%s[%s] = %s\n", name, i, arr[i]
+ }
+ }
+}
diff --git a/test/typeof4.ok b/test/typeof4.ok
new file mode 100644
index 00000000..fca0263d
--- /dev/null
+++ b/test/typeof4.ok
@@ -0,0 +1 @@
+a[x][y][z] = scalar