diff options
-rw-r--r-- | test/ChangeLog | 5 | ||||
-rw-r--r-- | test/Makefile.in | 9 | ||||
-rw-r--r-- | test/Maketests | 5 | ||||
-rw-r--r-- | test/strnum2.awk | 20 | ||||
-rw-r--r-- | test/strnum2.ok | 2 |
5 files changed, 34 insertions, 7 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index 5a575841..f5dbd571 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,8 @@ +2016-06-22 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * strnum2.awk, strnum2.ok: Improve test case to show both OFMT and + CONVFMT conversions. + 2016-06-20 Andrew J. Schorr <aschorr@telemetry-investments.com> * Makefile.am (strnum2): New test. diff --git a/test/Makefile.in b/test/Makefile.in index 11176f1f..be42a250 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -1256,6 +1256,8 @@ EXTRA_DIST = \ strftlng.ok \ strnum1.awk \ strnum1.ok \ + strnum2.awk \ + strnum2.ok \ strtod.awk \ strtod.in \ strtod.ok \ @@ -1421,7 +1423,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 strtod subamp subback subi18n \ + splitvar splitwht 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 \ @@ -3647,6 +3649,11 @@ strnum1: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +strnum2: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + strtod: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/Maketests b/test/Maketests index 4ee6f384..f42ecdc6 100644 --- a/test/Maketests +++ b/test/Maketests @@ -897,6 +897,11 @@ strnum1: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +strnum2: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + strtod: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/strnum2.awk b/test/strnum2.awk index 16e6f5d0..44931d5f 100644 --- a/test/strnum2.awk +++ b/test/strnum2.awk @@ -1,10 +1,18 @@ BEGIN { - split("1.234", f) + split(" 1.234 ", f, "|") # create a numeric string (strnum) value OFMT = "%.1f" - # check whether strnum is displayed the same way before and + CONVFMT = "%.2f" + + # Check whether a strnum is displayed the same way before and # after force_number is called. Also, should numeric strings - # be formatted with OFMT or show the original string value? - print f[1] - x = f[1]+0 # trigger conversion to NUMBER - print f[1] + # be formatted with OFMT and CONVFMT or show the original string value? + + print f[1] # OFMT + print (f[1] "") # CONVFMT + + # force conversion to NUMBER if it has not happened already + x = f[1]+0 + + print f[1] # OFMT + print (f[1] "") # CONVFMT } diff --git a/test/strnum2.ok b/test/strnum2.ok index f5103ca9..65cfbde2 100644 --- a/test/strnum2.ok +++ b/test/strnum2.ok @@ -1,2 +1,4 @@ 1.2 +1.23 1.2 +1.23 |