aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/ChangeLog7
-rw-r--r--test/arraysort.awk20
-rw-r--r--test/arraysort.ok8
-rw-r--r--test/sort1.awk46
-rw-r--r--test/sort1.ok146
-rw-r--r--test/sortfor.awk4
6 files changed, 146 insertions, 85 deletions
diff --git a/test/ChangeLog b/test/ChangeLog
index b3e99c2c..03c93594 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,10 @@
+Wed May 4 23:37:27 2011 Arnold D. Robbins <arnold@skeeve.com>
+
+ Revise tests for array sorting.
+
+ * arraysort.awk, arraysort.ok, sort1.awk, sort1.ok,
+ sortfor.awk: Revised.
+
Wed May 4 23:07:39 2011 Arnold D. Robbins <arnold@skeeve.com>
* nastyparm.awk, nastyparm.ok: New files from John Haque.
diff --git a/test/arraysort.awk b/test/arraysort.awk
index 09922044..b053a1d9 100644
--- a/test/arraysort.awk
+++ b/test/arraysort.awk
@@ -18,7 +18,7 @@ BEGIN {
BEGIN {
print "--- test2 ---"
a[100] = a[1] = a["x"] = a["y"] = 1
- PROCINFO["sorted_in"] = "num"
+ PROCINFO["sorted_in"] = "@ind_num_asc"
for (i in a)
print i, a[i]
delete a
@@ -27,7 +27,7 @@ BEGIN {
BEGIN {
print "--- test3 ---"
a[100] = a[1] = a["x"] = 1
- PROCINFO["sorted_in"] = "num"
+ PROCINFO["sorted_in"] = "@ind_num_asc"
for (i in a)
print i, a[i]
delete a
@@ -36,7 +36,7 @@ BEGIN {
BEGIN {
print "--- test4 ---"
a[0] = a[100] = a[1] = a["x"] = 1
- PROCINFO["sorted_in"] = "num"
+ PROCINFO["sorted_in"] = "@ind_num_asc"
for (i in a)
print i, a[i]
delete a
@@ -45,7 +45,7 @@ BEGIN {
BEGIN {
print "--- test5 ---"
a[""] = a["y"] = a[0] = 1
- PROCINFO["sorted_in"] = "num"
+ PROCINFO["sorted_in"] = "@ind_num_asc"
for (i in a)
print i, a[i]
delete a
@@ -54,7 +54,7 @@ BEGIN {
BEGIN {
print "--- test6 ---"
a[2] = a[1] = a[4] = a["3 "] = 1
- PROCINFO["sorted_in"] = "num"
+ PROCINFO["sorted_in"] = "@ind_num_asc"
for (i in a)
print "\""i"\""
delete a
@@ -67,24 +67,24 @@ BEGIN {
for (i = 1; i <= n; i++)
b[a[i]] = a[i]
print "--unsorted--"
- PROCINFO["sorted_in"] = "unsorted"
+ PROCINFO["sorted_in"] = "@unsorted"
for (i in b)
print "|"i"|"b[i]"|"
print "--asc ind str--"
- PROCINFO["sorted_in"] = "asc ind str"
+ PROCINFO["sorted_in"] = "@ind_str_asc"
for (i in b)
print "|"i"|"b[i]"|"
print "--asc val str--"
- PROCINFO["sorted_in"] = "asc val str"
+ PROCINFO["sorted_in"] = "@val_str_asc"
for (i in b)
print "|"i"|"b[i]"|"
print "--asc ind num--"
- PROCINFO["sorted_in"] = "asc ind num"
+ PROCINFO["sorted_in"] = "@ind_num_asc"
for (i in b)
print "|"i"|"b[i]"|"
print "--asc val num--"
- PROCINFO["sorted_in"] = "asc val num"
+ PROCINFO["sorted_in"] = "@val_num_asc"
for (i in b)
print "|"i"|"b[i]"|"
}
diff --git a/test/arraysort.ok b/test/arraysort.ok
index 70af0e01..454badf0 100644
--- a/test/arraysort.ok
+++ b/test/arraysort.ok
@@ -1,7 +1,7 @@
--- test1 ---
+ 5 5
10 10
3D 3D
- 5 5
--- test2 ---
x 1
y 1
@@ -71,13 +71,13 @@ y 1
|4|4|
|5|5|
--asc val num--
-|0|0|
|D3|D3|
+|0|0|
|1|1|
|2|2|
+|3D|3D|
| 3| 3|
|3|3|
-|3D|3D|
-| 4 | 4 |
|4|4|
+| 4 | 4 |
|5|5|
diff --git a/test/sort1.awk b/test/sort1.awk
index 44af59ff..ef28e9cd 100644
--- a/test/sort1.awk
+++ b/test/sort1.awk
@@ -16,38 +16,52 @@ BEGIN{
printf("---end asort(a, a), IGNORECASE = %d---\n", IGNORECASE)
makea(a)
- SORT_STR = "num"
+ SORT_STR = "@ind_num_asc"
asort2(a, "")
- printf("---end asort(a, b, \"num\"), IGNORECASE = %d---\n", IGNORECASE)
+ printf("---end asort(a, b, \"%s\"), IGNORECASE = %d---\n",
+ SORT_STR, IGNORECASE)
makea(a)
- SORT_STR = "desc str"
+ SORT_STR = "@ind_str_desc"
asort1(a, "")
- printf("---end asort(a, a, \"desc str\"), IGNORECASE = %d---\n", IGNORECASE)
+ printf("---end asort(a, a, \"%s\"), IGNORECASE = %d---\n",
+ SORT_STR, IGNORECASE)
makea(a)
- SORT_STR = "val str"
+ SORT_STR = "@val_str_asc"
proc_sort(a, "")
- printf("---end PROCINFO[\"sorted_in\"] = \"val str\", IGNORECASE = %d---\n",
- IGNORECASE)
+ printf("---end PROCINFO[\"sorted_in\"] = \"%s\", IGNORECASE = %d---\n",
+ SORT_STR, IGNORECASE)
makea(a)
- SORT_STR = "val num"
+ SORT_STR = "@val_num_asc"
proc_sort(a, "")
- printf("---end PROCINFO[\"sorted_in\"] = \"val num\", IGNORECASE = %d---\n",
- IGNORECASE)
+ printf("---end PROCINFO[\"sorted_in\"] = \"%s\", IGNORECASE = %d---\n",
+ SORT_STR, IGNORECASE)
makea(a)
- SORT_STR = "desc val str"
+ SORT_STR = "@val_str_desc"
proc_sort(a, "")
- printf("---end PROCINFO[\"sorted_in\"] = \"desc val str\", IGNORECASE = %d---\n",
- IGNORECASE)
+ printf("---end PROCINFO[\"sorted_in\"] = \"%s\", IGNORECASE = %d---\n",
+ SORT_STR, IGNORECASE)
makea(a)
- SORT_STR = "desc val num"
+ SORT_STR = "@val_num_desc"
proc_sort(a, "")
- printf("---end PROCINFO[\"sorted_in\"] = \"desc val num\", IGNORECASE = %d---\n",
- IGNORECASE)
+ printf("---end PROCINFO[\"sorted_in\"] = \"%s\", IGNORECASE = %d---\n",
+ SORT_STR, IGNORECASE)
+
+ makea(a)
+ SORT_STR = "@val_type_asc"
+ proc_sort(a, "")
+ printf("---end PROCINFO[\"sorted_in\"] = \"%s\", IGNORECASE = %d---\n",
+ SORT_STR, IGNORECASE)
+
+ makea(a)
+ SORT_STR = "@val_type_desc"
+ proc_sort(a, "")
+ printf("---end PROCINFO[\"sorted_in\"] = \"%s\", IGNORECASE = %d---\n",
+ SORT_STR, IGNORECASE)
}
}
diff --git a/test/sort1.ok b/test/sort1.ok
index 8ba2bcd2..2d43e31a 100644
--- a/test/sort1.ok
+++ b/test/sort1.ok
@@ -1,5 +1,5 @@
- [1]: 1234
- [2]: 234
+ [1]: 234
+ [2]: 1234
[3]: Zebra
[4]: barz
[5]: blattt
@@ -8,8 +8,8 @@
[6][3]: tttalb
[6][4]: zrab
---end asort(a), IGNORECASE = 0---
- [1]: barz 1234
- [2]: blattt 234
+ [1]: barz 234
+ [2]: blattt 1234
[3]: Zebra Zebra
[4]: 1234 barz
[5]: 234 blattt
@@ -18,8 +18,8 @@
[6][3]: tttalb tttalb
[6][4]: zrab zrab
---end asort(a, b), IGNORECASE = 0---
- [1]: 1234
- [2]: 234
+ [1]: 234
+ [2]: 1234
[3]: Zebra
[4]: barz
[5]: blattt
@@ -28,26 +28,26 @@
[6][3]: tttalb
[6][4]: zrab
---end asort(a, a), IGNORECASE = 0---
- [1]: barz Zebra
- [2]: blattt barz
- [3]: Zebra blattt
- [4]: 1234 234
- [5]: 234 1234
- [6][1]: 4321 arbeZ
- [6][2]: arbeZ tttalb
- [6][3]: tttalb zrab
- [6][4]: zrab 4321
----end asort(a, b, "num"), IGNORECASE = 0---
+ [1]: barz barz
+ [2]: blattt blattt
+ [3]: Zebra Zebra
+ [4]: 1234 1234
+ [5]: 234 234
+ [6][1]: 4321 4321
+ [6][2]: arbeZ arbeZ
+ [6][3]: tttalb tttalb
+ [6][4]: zrab zrab
+---end asort(a, b, "@ind_num_asc"), IGNORECASE = 0---
[1][1]: zrab
[1][2]: tttalb
[1][3]: arbeZ
[1][4]: 4321
- [2]: blattt
- [3]: barz
+ [2]: 234
+ [3]: 1234
[4]: Zebra
- [5]: 234
- [6]: 1234
----end asort(a, a, "desc str"), IGNORECASE = 0---
+ [5]: blattt
+ [6]: barz
+---end asort(a, a, "@ind_str_desc"), IGNORECASE = 0---
[4]: 1234
[5]: 234
[3]: Zebra
@@ -57,17 +57,17 @@
[6][2]: arbeZ
[6][3]: tttalb
[6][4]: zrab
----end PROCINFO["sorted_in"] = "val str", IGNORECASE = 0---
- [3]: Zebra
+---end PROCINFO["sorted_in"] = "@val_str_asc", IGNORECASE = 0---
[1]: barz
[2]: blattt
+ [3]: Zebra
[5]: 234
[4]: 1234
+ [6][4]: zrab
[6][2]: arbeZ
[6][3]: tttalb
- [6][4]: zrab
[6][1]: 4321
----end PROCINFO["sorted_in"] = "val num", IGNORECASE = 0---
+---end PROCINFO["sorted_in"] = "@val_num_asc", IGNORECASE = 0---
[6][4]: zrab
[6][3]: tttalb
[6][2]: arbeZ
@@ -77,19 +77,39 @@
[3]: Zebra
[5]: 234
[4]: 1234
----end PROCINFO["sorted_in"] = "desc val str", IGNORECASE = 0---
+---end PROCINFO["sorted_in"] = "@val_str_desc", IGNORECASE = 0---
[6][1]: 4321
[6][4]: zrab
- [6][3]: tttalb
[6][2]: arbeZ
+ [6][3]: tttalb
[4]: 1234
[5]: 234
+ [1]: barz
+ [2]: blattt
+ [3]: Zebra
+---end PROCINFO["sorted_in"] = "@val_num_desc", IGNORECASE = 0---
+ [5]: 234
+ [4]: 1234
+ [3]: Zebra
+ [1]: barz
+ [2]: blattt
+ [6][1]: 4321
+ [6][2]: arbeZ
+ [6][3]: tttalb
+ [6][4]: zrab
+---end PROCINFO["sorted_in"] = "@val_type_asc", IGNORECASE = 0---
+ [6][4]: zrab
+ [6][3]: tttalb
+ [6][2]: arbeZ
+ [6][1]: 4321
[2]: blattt
[1]: barz
[3]: Zebra
----end PROCINFO["sorted_in"] = "desc val num", IGNORECASE = 0---
- [1]: 1234
- [2]: 234
+ [4]: 1234
+ [5]: 234
+---end PROCINFO["sorted_in"] = "@val_type_desc", IGNORECASE = 0---
+ [1]: 234
+ [2]: 1234
[3]: barz
[4]: blattt
[5]: Zebra
@@ -98,8 +118,8 @@
[6][3]: tttalb
[6][4]: zrab
---end asort(a), IGNORECASE = 1---
- [1]: barz 1234
- [2]: blattt 234
+ [1]: barz 234
+ [2]: blattt 1234
[3]: Zebra barz
[4]: 1234 blattt
[5]: 234 Zebra
@@ -108,8 +128,8 @@
[6][3]: tttalb tttalb
[6][4]: zrab zrab
---end asort(a, b), IGNORECASE = 1---
- [1]: 1234
- [2]: 234
+ [1]: 234
+ [2]: 1234
[3]: barz
[4]: blattt
[5]: Zebra
@@ -121,23 +141,23 @@
[1]: barz barz
[2]: blattt blattt
[3]: Zebra Zebra
- [4]: 1234 234
- [5]: 234 1234
- [6][1]: 4321 arbeZ
- [6][2]: arbeZ tttalb
- [6][3]: tttalb zrab
- [6][4]: zrab 4321
----end asort(a, b, "num"), IGNORECASE = 1---
+ [4]: 1234 1234
+ [5]: 234 234
+ [6][1]: 4321 4321
+ [6][2]: arbeZ arbeZ
+ [6][3]: tttalb tttalb
+ [6][4]: zrab zrab
+---end asort(a, b, "@ind_num_asc"), IGNORECASE = 1---
[1][1]: zrab
[1][2]: tttalb
[1][3]: arbeZ
[1][4]: 4321
- [2]: Zebra
- [3]: blattt
- [4]: barz
- [5]: 234
- [6]: 1234
----end asort(a, a, "desc str"), IGNORECASE = 1---
+ [2]: 234
+ [3]: 1234
+ [4]: Zebra
+ [5]: blattt
+ [6]: barz
+---end asort(a, a, "@ind_str_desc"), IGNORECASE = 1---
[4]: 1234
[5]: 234
[1]: barz
@@ -147,17 +167,17 @@
[6][2]: arbeZ
[6][3]: tttalb
[6][4]: zrab
----end PROCINFO["sorted_in"] = "val str", IGNORECASE = 1---
+---end PROCINFO["sorted_in"] = "@val_str_asc", IGNORECASE = 1---
[1]: barz
[2]: blattt
[3]: Zebra
[5]: 234
[4]: 1234
+ [6][4]: zrab
[6][2]: arbeZ
[6][3]: tttalb
- [6][4]: zrab
[6][1]: 4321
----end PROCINFO["sorted_in"] = "val num", IGNORECASE = 1---
+---end PROCINFO["sorted_in"] = "@val_num_asc", IGNORECASE = 1---
[6][4]: zrab
[6][3]: tttalb
[6][2]: arbeZ
@@ -167,14 +187,34 @@
[1]: barz
[5]: 234
[4]: 1234
----end PROCINFO["sorted_in"] = "desc val str", IGNORECASE = 1---
+---end PROCINFO["sorted_in"] = "@val_str_desc", IGNORECASE = 1---
[6][1]: 4321
[6][4]: zrab
- [6][3]: tttalb
[6][2]: arbeZ
+ [6][3]: tttalb
[4]: 1234
[5]: 234
+ [1]: barz
+ [2]: blattt
+ [3]: Zebra
+---end PROCINFO["sorted_in"] = "@val_num_desc", IGNORECASE = 1---
+ [5]: 234
+ [4]: 1234
+ [1]: barz
+ [2]: blattt
+ [3]: Zebra
+ [6][1]: 4321
+ [6][2]: arbeZ
+ [6][3]: tttalb
+ [6][4]: zrab
+---end PROCINFO["sorted_in"] = "@val_type_asc", IGNORECASE = 1---
+ [6][4]: zrab
+ [6][3]: tttalb
+ [6][2]: arbeZ
+ [6][1]: 4321
[3]: Zebra
[2]: blattt
[1]: barz
----end PROCINFO["sorted_in"] = "desc val num", IGNORECASE = 1---
+ [4]: 1234
+ [5]: 234
+---end PROCINFO["sorted_in"] = "@val_type_desc", IGNORECASE = 1---
diff --git a/test/sortfor.awk b/test/sortfor.awk
index 611eca64..922b5e85 100644
--- a/test/sortfor.awk
+++ b/test/sortfor.awk
@@ -1,9 +1,9 @@
{ a[$0]++ }
END {
- PROCINFO["sorted_in"] = "ascending"
+ PROCINFO["sorted_in"] = "@ind_str_asc"
for (i in a)
print i
- PROCINFO["sorted_in"] = "descending"
+ PROCINFO["sorted_in"] = "@ind_str_desc"
for (i in a)
print i
}