From 140a4a886edc231f1c5f02c6cd4c82effe58139e Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Sat, 23 Jul 2016 21:59:40 +0300 Subject: Fix do_print for use with strnums. --- test/ChangeLog | 5 +++++ test/Makefile.am | 5 ++++- test/Makefile.in | 10 +++++++++- test/Maketests | 5 +++++ test/ofmtstrnum.awk | 7 +++++++ test/ofmtstrnum.ok | 2 ++ 6 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 test/ofmtstrnum.awk create mode 100644 test/ofmtstrnum.ok (limited to 'test') diff --git a/test/ChangeLog b/test/ChangeLog index f7c28922..8939b6f4 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,8 @@ +2015-06-17 Arnold D. Robbins + + * Makefile.am (ofmtstrnum): New test. + * ofmtstrnu.awk, ofmtstrnum.ok: New files. + 2016-07-01 Arnold D. Robbins * arrayind1.awk, arrayind1.ok: Comment out prints to stderr to diff --git a/test/Makefile.am b/test/Makefile.am index 34cc954b..0bda377c 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -674,6 +674,8 @@ EXTRA_DIST = \ ofmts.awk \ ofmts.in \ ofmts.ok \ + ofmtstrnum.awk \ + ofmtstrnum.ok \ ofs1.awk \ ofs1.in \ ofs1.ok \ @@ -1080,7 +1082,8 @@ BASIC_TESTS = \ nasty nasty2 negexp negrange nested nfldstr nfloop nfneg nfset nlfldsep \ nlinstr nlstrina noeffect nofile nofmtch noloop1 noloop2 nonl \ noparms nors nulinsrc nulrsend numindex numsubstr \ - octsub ofmt ofmta ofmtbig ofmtfidl ofmts ofs1 onlynl opasnidx opasnslf \ + octsub ofmt ofmta ofmtbig ofmtfidl ofmts ofmtstrnum ofs1 onlynl \ + opasnidx opasnslf \ paramasfunc1 paramasfunc2 \ paramdup paramres paramtyp paramuninitglobal parse1 parsefld parseme \ pcntplus posix2008sub prdupval prec printf0 printf1 prmarscl prmreuse \ diff --git a/test/Makefile.in b/test/Makefile.in index 5baefb40..ff1d8e07 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -931,6 +931,8 @@ EXTRA_DIST = \ ofmts.awk \ ofmts.in \ ofmts.ok \ + ofmtstrnum.awk \ + ofmtstrnum.ok \ ofs1.awk \ ofs1.in \ ofs1.ok \ @@ -1336,7 +1338,8 @@ BASIC_TESTS = \ nasty nasty2 negexp negrange nested nfldstr nfloop nfneg nfset nlfldsep \ nlinstr nlstrina noeffect nofile nofmtch noloop1 noloop2 nonl \ noparms nors nulinsrc nulrsend numindex numsubstr \ - octsub ofmt ofmta ofmtbig ofmtfidl ofmts ofs1 onlynl opasnidx opasnslf \ + octsub ofmt ofmta ofmtbig ofmtfidl ofmts ofmtstrnum ofs1 onlynl \ + opasnidx opasnslf \ paramasfunc1 paramasfunc2 \ paramdup paramres paramtyp paramuninitglobal parse1 parsefld parseme \ pcntplus posix2008sub prdupval prec printf0 printf1 prmarscl prmreuse \ @@ -3233,6 +3236,11 @@ ofmts: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +ofmtstrnum: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + ofs1: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/Maketests b/test/Maketests index 57b5c5ad..7d50a4b3 100644 --- a/test/Maketests +++ b/test/Maketests @@ -620,6 +620,11 @@ ofmts: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +ofmtstrnum: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + ofs1: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/ofmtstrnum.awk b/test/ofmtstrnum.awk new file mode 100644 index 00000000..805dad73 --- /dev/null +++ b/test/ofmtstrnum.awk @@ -0,0 +1,7 @@ +BEGIN { + split(" 1", f, "|") + OFMT = "%.1f" + print f[1] + x = f[1] + 0 + print f[1] +} diff --git a/test/ofmtstrnum.ok b/test/ofmtstrnum.ok new file mode 100644 index 00000000..ae955868 --- /dev/null +++ b/test/ofmtstrnum.ok @@ -0,0 +1,2 @@ + 1 + 1 -- cgit v1.2.3 From de23ab7bfbea6ee03ef7386c6c203a4b2b7b7116 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Sat, 23 Jul 2016 22:10:25 +0300 Subject: Make return status of close on a pipe like system. --- test/ChangeLog | 5 +++++ test/Makefile.am | 4 +++- test/Makefile.in | 9 ++++++++- test/Maketests | 5 +++++ test/status-close.awk | 14 ++++++++++++++ test/status-close.ok | 6 ++++++ 6 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 test/status-close.awk create mode 100644 test/status-close.ok (limited to 'test') diff --git a/test/ChangeLog b/test/ChangeLog index 08196ead..f159be72 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,8 @@ +2016-07-23 Arnold D. Robbins + + * Makefile.am (status-close): New test. + * status-close.awk, status-close.ok: New files. + 2015-06-17 Arnold D. Robbins * Makefile.am (ofmtstrnum): New test. diff --git a/test/Makefile.am b/test/Makefile.am index 5fa153eb..40636acd 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -997,6 +997,8 @@ EXTRA_DIST = \ sprintfc.awk \ sprintfc.in \ sprintfc.ok \ + status-close.awk \ + status-close.ok \ strcat1.awk \ strcat1.ok \ strftime.awk \ @@ -1173,7 +1175,7 @@ BASIC_TESTS = \ reparse resplit rri1 rs rscompat rsnul1nl rsnulbig rsnulbig2 rstest1 rstest2 \ rstest3 rstest4 rstest5 rswhite \ scalar sclforin sclifin sigpipe1 sortempty sortglos splitargv splitarr splitdef \ - splitvar splitwht strcat1 strnum1 strnum2 strtod subamp subback subi18n \ + splitvar splitwht status-close strcat1 strnum1 strnum2 strtod subamp subback subi18n \ subsepnm subslash substr swaplns synerr1 synerr2 tradanch tweakfld \ uninit2 uninit3 uninit4 uninit5 uninitialized unterm uparrfs \ wideidx wideidx2 widesub widesub2 widesub3 widesub4 wjposer1 \ diff --git a/test/Makefile.in b/test/Makefile.in index 900054f7..beb2af2d 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -1254,6 +1254,8 @@ EXTRA_DIST = \ sprintfc.awk \ sprintfc.in \ sprintfc.ok \ + status-close.awk \ + status-close.ok \ strcat1.awk \ strcat1.ok \ strftime.awk \ @@ -1429,7 +1431,7 @@ BASIC_TESTS = \ reparse resplit rri1 rs rscompat rsnul1nl rsnulbig rsnulbig2 rstest1 rstest2 \ rstest3 rstest4 rstest5 rswhite \ scalar sclforin sclifin sigpipe1 sortempty sortglos splitargv splitarr splitdef \ - splitvar splitwht strcat1 strnum1 strnum2 strtod subamp subback subi18n \ + splitvar splitwht status-close strcat1 strnum1 strnum2 strtod subamp subback subi18n \ subsepnm subslash substr swaplns synerr1 synerr2 tradanch tweakfld \ uninit2 uninit3 uninit4 uninit5 uninitialized unterm uparrfs \ wideidx wideidx2 widesub widesub2 widesub3 widesub4 wjposer1 \ @@ -3655,6 +3657,11 @@ splitwht: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +status-close: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + strcat1: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/Maketests b/test/Maketests index 16586ae9..d9b4fe09 100644 --- a/test/Maketests +++ b/test/Maketests @@ -897,6 +897,11 @@ splitwht: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +status-close: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + strcat1: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/status-close.awk b/test/status-close.awk new file mode 100644 index 00000000..345bea49 --- /dev/null +++ b/test/status-close.awk @@ -0,0 +1,14 @@ +BEGIN { + cat = "cat ; exit 3" + print system("echo xxx | (cat ; exit 4)") + + print "YYY" | cat + + print close(cat) + + echo = "echo boo ; exit 5" + echo | getline boo + print "got", boo + + print close(echo) +} diff --git a/test/status-close.ok b/test/status-close.ok new file mode 100644 index 00000000..ad3c0ce1 --- /dev/null +++ b/test/status-close.ok @@ -0,0 +1,6 @@ +xxx +4 +YYY +3 +got boo +5 -- cgit v1.2.3