diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2012-06-25 22:05:42 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2012-06-25 22:05:42 +0300 |
commit | 2d0d82f7453b1c5ad5e1baa8c02c2f6d5e5ccb67 (patch) | |
tree | bd3464a03480eed31aacc43b9cf80c468a8f2fa6 /test/rwarray.awk | |
parent | 7642bd16ac81fbf85247ab2b5768cb6b316c8419 (diff) | |
download | egawk-2d0d82f7453b1c5ad5e1baa8c02c2f6d5e5ccb67.tar.gz egawk-2d0d82f7453b1c5ad5e1baa8c02c2f6d5e5ccb67.tar.bz2 egawk-2d0d82f7453b1c5ad5e1baa8c02c2f6d5e5ccb67.zip |
Add rwarray to extension tests.
Diffstat (limited to 'test/rwarray.awk')
-rw-r--r-- | test/rwarray.awk | 33 |
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") +} |