aboutsummaryrefslogtreecommitdiffstats
path: root/test/rwarray.awk
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2012-08-17 12:38:04 +0300
committerArnold D. Robbins <arnold@skeeve.com>2012-08-17 12:38:04 +0300
commite6b05afd9971b457c0b46907a91185b66be8ff4e (patch)
treee7d3b6fce47a2ac7b32cdf923ceb6e50db9fe441 /test/rwarray.awk
parent3b23e177cd166e96c700379491b4a99bddf9aa4d (diff)
parent76cc4d241f328876b18e48639d631823c3d304d6 (diff)
downloadegawk-e6b05afd9971b457c0b46907a91185b66be8ff4e.tar.gz
egawk-e6b05afd9971b457c0b46907a91185b66be8ff4e.tar.bz2
egawk-e6b05afd9971b457c0b46907a91185b66be8ff4e.zip
Merge branch 'extgawk'
Diffstat (limited to 'test/rwarray.awk')
-rw-r--r--test/rwarray.awk33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/rwarray.awk b/test/rwarray.awk
new file mode 100644
index 00000000..5d1b7e9d
--- /dev/null
+++ b/test/rwarray.awk
@@ -0,0 +1,33 @@
+@load "rwarray"
+
+BEGIN {
+ while ((getline word) > 0)
+ dict[word] = word word
+
+ n = asorti(dict, dictindices)
+ for (i = 1; i <= n; i++)
+ printf("dict[%s] = %s\n", dictindices[i], dict[dictindices[i]]) > "orig.out"
+ close("orig.out");
+
+ ret = writea("orig.bin", dict)
+ printf "writea() returned %d, expecting 1\n", ret
+
+
+ ret = reada("orig.bin", dict)
+ printf "reada() returned %d, expecting 1\n", ret
+
+ n = asorti(dict, dictindices)
+ for (i = 1; i <= n; i++)
+ printf("dict[%s] = %s\n", dictindices[i], dict[dictindices[i]]) > "new.out"
+ close("new.out");
+
+ ret = system("cmp orig.out new.out")
+
+ if (ret == 0)
+ print "old and new are equal - GOOD"
+ else
+ print "old and new are not equal - BAD"
+
+ if (ret == 0 && !("KEEPIT" in ENVIRON))
+ system("rm -f orig.bin orig.out new.out")
+}