1@load "rwarray" 2 3BEGIN { 4 while ((getline word) > 0) 5 dict[word] = word word 6 7 re_sub = "/typed-regex/" 8 dict[re_sub] = @/search me/ 9 10 strnum_sub = "strnum-sub" 11 split("-2.4", f) 12 dict[strnum_sub] = f[1] 13 14 n = asorti(dict, dictindices) 15 for (i = 1; i <= n; i++) 16 printf("dict[%s] = %s\n", dictindices[i], dict[dictindices[i]]) > "orig.out" 17 close("orig.out"); 18 19 ret = writea("orig.bin", dict) 20 printf "writea() returned %d, expecting 1\n", ret 21 22 ret = reada("orig.bin", dict) 23 printf "reada() returned %d, expecting 1\n", ret 24 25 n = asorti(dict, dictindices) 26 for (i = 1; i <= n; i++) 27 printf("dict[%s] = %s\n", dictindices[i], dict[dictindices[i]]) > "new.out" 28 close("new.out"); 29 30 os = "" 31 if (ENVIRON["AWKLIBPATH"] == "sys$disk:[-]") { 32 os = "VMS" 33 # return status from system() on VMS can not be used here 34 } 35 if (os != "VMS") { 36 ret = system("cmp orig.out new.out") 37 38 if (ret == 0) 39 print "old and new are equal - GOOD" 40 else 41 print "old and new are not equal - BAD" 42 43 if (ret == 0 && !("KEEPIT" in ENVIRON)) 44 system("rm -f orig.bin orig.out new.out") 45 } 46 47 if (typeof(dict[re_sub]) != "regexp") 48 printf("dict[\"%s\"] should be regexp, is %s\n", 49 re_sub, typeof(dict[re_sub])); 50 51 if (typeof(dict[strnum_sub]) != "strnum") 52 printf("dict[\"%s\"] should be strnum, is %s\n", 53 strnum_sub, typeof(dict[strnum_sub])); 54} 55