aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2016-05-12 22:39:48 +0300
committerArnold D. Robbins <arnold@skeeve.com>2016-05-12 22:39:48 +0300
commitd7b4254cbf5f70d430e21f4f8ca90e354e251bac (patch)
treeebead5b02dae267232b6e597612704f9a3697235 /test
parent9205d5d6fd20ad78918b44100063ade0b1374ede (diff)
parent29f8ff8ee26d1c5c3fad9129786687c745322494 (diff)
downloadegawk-d7b4254cbf5f70d430e21f4f8ca90e354e251bac.tar.gz
egawk-d7b4254cbf5f70d430e21f4f8ca90e354e251bac.tar.bz2
egawk-d7b4254cbf5f70d430e21f4f8ca90e354e251bac.zip
Merge branch 'gawk-4.1-stable'
Diffstat (limited to 'test')
-rw-r--r--test/ChangeLog7
-rw-r--r--test/Makefile.am9
-rw-r--r--test/Makefile.in19
-rw-r--r--test/Maketests10
-rwxr-xr-xtest/arrayind1.awk99
-rw-r--r--test/arrayind1.in2
-rw-r--r--test/arrayind1.ok9
-rw-r--r--test/sigpipe1.awk13
-rw-r--r--test/sigpipe1.ok3
9 files changed, 167 insertions, 4 deletions
diff --git a/test/ChangeLog b/test/ChangeLog
index d9ec5498..096f9050 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,10 @@
+2016-05-12 Arnold D. Robbins <arnold@skeeve.com>
+
+ * Makefile.am (arrayind1): New test.
+ * arrayind1.awk, arrayind1.in, arrayind1.ok: New files.
+ * Makefile.am (sigpipe1): New test.
+ * sigpipe1.awk, sigpipe1.ok: New files.
+
2016-04-27 Arnold D. Robbins <arnold@skeeve.com>
* Makefile.am (rscompat): New test.
diff --git a/test/Makefile.am b/test/Makefile.am
index ea483401..63990647 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -52,6 +52,9 @@ EXTRA_DIST = \
argarray.ok \
argtest.awk \
argtest.ok \
+ arrayind1.awk \
+ arrayind1.in \
+ arrayind1.ok \
arrayparm.awk \
arrayparm.ok \
arrayprm2.awk \
@@ -923,6 +926,8 @@ EXTRA_DIST = \
shadow.ok \
shadowbuiltin.awk \
shadowbuiltin.ok \
+ sigpipe1.awk \
+ sigpipe1.ok \
sort1.awk \
sort1.ok \
sortempty.awk \
@@ -1089,7 +1094,7 @@ CLEANFILES = core core.* fmtspcl.ok
# try to keep these sorted. each letter starts a new line
BASIC_TESTS = \
- addcomma anchgsub argarray arrayparm arrayprm2 arrayprm3 \
+ addcomma anchgsub argarray arrayind1 arrayparm arrayprm2 arrayprm3 \
arrayref arrymem1 arryref2 arryref3 arryref4 arryref5 arynasty \
arynocls aryprm1 aryprm2 aryprm3 aryprm4 aryprm5 aryprm6 aryprm7 \
aryprm8 aryprm9 arysubnm asgext awkpath \
@@ -1121,7 +1126,7 @@ BASIC_TESTS = \
regexprange regrange reindops \
reparse resplit rri1 rs rscompat rsnul1nl rsnulbig rsnulbig2 rstest1 rstest2 \
rstest3 rstest4 rstest5 rswhite \
- scalar sclforin sclifin sortempty sortglos splitargv splitarr splitdef \
+ scalar sclforin sclifin sigpipe1 sortempty sortglos splitargv splitarr splitdef \
splitvar splitwht strcat1 strnum1 strtod subamp subi18n \
subsepnm subslash substr swaplns synerr1 synerr2 tradanch tweakfld \
uninit2 uninit3 uninit4 uninit5 uninitialized unterm uparrfs \
diff --git a/test/Makefile.in b/test/Makefile.in
index 7cbf8003..cc44371c 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -309,6 +309,9 @@ EXTRA_DIST = \
argarray.ok \
argtest.awk \
argtest.ok \
+ arrayind1.awk \
+ arrayind1.in \
+ arrayind1.ok \
arrayparm.awk \
arrayparm.ok \
arrayprm2.awk \
@@ -1180,6 +1183,8 @@ EXTRA_DIST = \
shadow.ok \
shadowbuiltin.awk \
shadowbuiltin.ok \
+ sigpipe1.awk \
+ sigpipe1.ok \
sort1.awk \
sort1.ok \
sortempty.awk \
@@ -1345,7 +1350,7 @@ CLEANFILES = core core.* fmtspcl.ok
# try to keep these sorted. each letter starts a new line
BASIC_TESTS = \
- addcomma anchgsub argarray arrayparm arrayprm2 arrayprm3 \
+ addcomma anchgsub argarray arrayind1 arrayparm arrayprm2 arrayprm3 \
arrayref arrymem1 arryref2 arryref3 arryref4 arryref5 arynasty \
arynocls aryprm1 aryprm2 aryprm3 aryprm4 aryprm5 aryprm6 aryprm7 \
aryprm8 aryprm9 arysubnm asgext awkpath \
@@ -1377,7 +1382,7 @@ BASIC_TESTS = \
regexprange regrange reindops \
reparse resplit rri1 rs rscompat rsnul1nl rsnulbig rsnulbig2 rstest1 rstest2 \
rstest3 rstest4 rstest5 rswhite \
- scalar sclforin sclifin sortempty sortglos splitargv splitarr splitdef \
+ scalar sclforin sclifin sigpipe1 sortempty sortglos splitargv splitarr splitdef \
splitvar splitwht strcat1 strnum1 strtod subamp subi18n \
subsepnm subslash substr swaplns synerr1 synerr2 tradanch tweakfld \
uninit2 uninit3 uninit4 uninit5 uninitialized unterm uparrfs \
@@ -2689,6 +2694,11 @@ anchgsub:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+arrayind1:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
arrayparm:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@@ -3501,6 +3511,11 @@ sclifin:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+sigpipe1:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
sortempty:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/Maketests b/test/Maketests
index d10c2e45..a831496c 100644
--- a/test/Maketests
+++ b/test/Maketests
@@ -10,6 +10,11 @@ anchgsub:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+arrayind1:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
arrayparm:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@@ -822,6 +827,11 @@ sclifin:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+sigpipe1:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
sortempty:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/arrayind1.awk b/test/arrayind1.awk
new file mode 100755
index 00000000..29fe80bc
--- /dev/null
+++ b/test/arrayind1.awk
@@ -0,0 +1,99 @@
+#!/usr/local/bin/awk -f
+# this script renums pedigrees with metafounders
+# so that they are added *before*regular animals
+# mf are ascertained because they are not in the 1st column
+# also ordered by generation assuming that all metafounders
+# start at generation 1
+#
+#
+ function maxval (a,b) {
+ max=b
+ if (a>b){max=a}
+ return max
+ }
+BEGIN{
+ pos[0]=0 # actual position in the original data file
+ changed=1
+ posout[0]=0 # position in the new file
+ last=0
+ cum[0]=0 #number of times it acts as parent
+ gen[0]=0
+}
+# read and store pedigree file
+{
+ pos[$1]=NR
+ dam[$1]=$2
+ sire[$1]=$3
+ included[$1]=0
+ gen[$1]=9999
+}
+END{
+ #printf("%10s%10s\n",NR,"animals") > "/dev/stderr"
+ # find out who is a genetic group
+ for (x in sire){
+ if(! (sire[x] in pos)){
+ is_group[sire[x]]=1
+ #printf("%10s%10s\n","sire",sire[x]) > "/dev/stderr"
+ cum[sire[x],"sire"]++
+ }
+ }
+ for (x in dam){
+ if(! (dam[x] in pos)){
+ is_group[dam[x]]=1
+ #printf("%10s%10s\n","dam",dam[x]) > "/dev/stderr"
+ cum[dam[x],"dam"]++
+ }
+ }
+ # compute numbers, but don't write them out
+ #printf("%16s\n","info on mf") > "/dev/stderr"
+ for (x in is_group){
+ nmf++
+ posout[x]=posout[last]+1
+ printf("%16s%16s%16s%16s%16s%16s%16s\n", posout[x],0,0,x,0,0,0)
+ included[x]=1
+ gen[x]=0
+ last=x
+ cumgen[0]++
+ #printf("%10s%16s%10s%16s%10s%10s%10s\n","group",last," included as",posout[x]," as sire, as dam",cum[x,"sire"],cum[x,"dam"]) > "/dev/stderr"
+ }
+ # regular individuals
+ printf("%16s\n","recoding animals") > "/dev/stderr"
+ iter=1
+ #--> comment next line and this element of the associative array becomes null
+ #printf("%s%16s\n","at the beginning it should be empty: ",posout["00000779770060"]) > "/dev/stderr"
+ #-->
+ while (changed){
+ changed=0
+ for (x in pos){
+ if(x!=0 && !included[x]){
+ # change to number of generation
+ # if(included[dam[x]] && included[sire[x]]){
+ if((gen[dam[x]]<iter) && (gen[sire[x]]<iter)){
+ # the new code is actually the order animals are printed
+ posout[x]=posout[last]+1
+ gen[x]=maxval(gen[dam[x]],gen[sire[x]])+1
+ printf("%16s%16s%16s%16s%16s%16s%16s\n", posout[x],posout[dam[x]],posout[sire[x]],x,dam[x],sire[x],gen[x])
+ included[x]=1
+ changed=1
+ last=x
+ nanim++
+ cumgen[gen[x]]++
+ }
+ # }
+ }
+ }
+ iter++
+ #-->
+ printf("%s%16s\n","in the loop: ",posout["00000779770060"]) > "/dev/stderr"
+ #-->
+ #printf("%10s%10s%10s%10s%16s%16s\n","round",iter,"included",posout[last],"last ",last) > "/dev/stderr"
+ }
+ #printf("%10s%10s%10s%10s%10s%10s\n","metafounders:",nmf," animals",nanim," total",posout[last]) > "/dev/stderr"
+ #printf("%16s%16s\n","pseudogenerations:",gen[last]) > "/dev/stderr"
+ for (x in cumgen){
+ #printf("%10s%16s%10s%16s\n","pseudogeneration:",x," including: ",cumgen[x]) > "/dev/stderr"
+ }
+ #--> this is the guilty line
+ printf("%s%16s\n","at the end: ",posout["00000779770060"]) > "/dev/stderr"
+ #-->
+}
diff --git a/test/arrayind1.in b/test/arrayind1.in
new file mode 100644
index 00000000..915d8657
--- /dev/null
+++ b/test/arrayind1.in
@@ -0,0 +1,2 @@
+64000757790003 00000779770060 00000757740011 1979 2 1975 0
+00000779770060 1975su1du1 1975su1du1 1975 1 1975 1975su1du1
diff --git a/test/arrayind1.ok b/test/arrayind1.ok
new file mode 100644
index 00000000..c68346ea
--- /dev/null
+++ b/test/arrayind1.ok
@@ -0,0 +1,9 @@
+recoding animals
+in the loop: 3
+in the loop: 3
+in the loop: 3
+at the end: 3
+ 1 0 0 00000757740011 0 0 0
+ 2 0 0 1975su1du1 0 0 0
+ 3 2 2 00000779770060 1975su1du1 1975su1du1 1
+ 4 3 1 64000757790003 00000779770060 00000757740011 2
diff --git a/test/sigpipe1.awk b/test/sigpipe1.awk
new file mode 100644
index 00000000..9b23f390
--- /dev/null
+++ b/test/sigpipe1.awk
@@ -0,0 +1,13 @@
+BEGIN {
+ print "system"
+ command = "yes | true"
+ system(command)
+
+ print "pipe to command"
+ print "hi" | command
+ close(command)
+
+ print "pipe from command"
+ command | getline x
+ close(command)
+}
diff --git a/test/sigpipe1.ok b/test/sigpipe1.ok
new file mode 100644
index 00000000..6596f076
--- /dev/null
+++ b/test/sigpipe1.ok
@@ -0,0 +1,3 @@
+system
+pipe to command
+pipe from command