diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/ChangeLog | 15 | ||||
-rw-r--r-- | test/Makefile.am | 18 | ||||
-rw-r--r-- | test/Makefile.in | 18 | ||||
-rw-r--r-- | test/badargs.ok | 2 | ||||
-rw-r--r-- | test/mpfrrem.awk | 6 | ||||
-rw-r--r-- | test/mpfrrem.ok | 4 | ||||
-rw-r--r-- | test/mpfrsqrt.awk | 82 | ||||
-rw-r--r-- | test/mpfrsqrt.ok | 2 | ||||
-rw-r--r-- | test/printhuge.awk | 2 | ||||
-rw-r--r-- | test/printhuge.ok | 2 |
10 files changed, 144 insertions, 7 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index cc921277..db9b1e35 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,18 @@ +2014-08-05 Arnold D. Robbins <arnold@skeeve.com> + + * Makefile.am (mpfrsqrt): New test. + * mpfrsqrt.awk, mpfrsqrt.ok: New files. + Test from Katie Wasserman <katie@wass.net>. + +2014-07-25 Arnold D. Robbins <arnold@skeeve.com> + + * printhuge.awk: Add a newline to output. + * printhuge.ok: Adjust. + +2014-07-24 Arnold D. Robbins <arnold@skeeve.com> + + * badargs.ok: Adjust after correctly alphabetizing options. + 2014-07-10 Arnold D. Robbins <arnold@skeeve.com> * Makefile.am (printhuge): New test. diff --git a/test/Makefile.am b/test/Makefile.am index d4ef501c..f28b381e 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -529,10 +529,14 @@ EXTRA_DIST = \ mpfrnr.awk \ mpfrnr.in \ mpfrnr.ok \ + mpfrrem.awk \ + mpfrrem.ok \ mpfrrnd.awk \ mpfrrnd.ok \ mpfrsort.awk \ mpfrsort.ok \ + mpfrsqrt.awk \ + mpfrsqrt.ok \ mtchi18n.awk \ mtchi18n.in \ mtchi18n.ok \ @@ -1024,8 +1028,8 @@ INET_TESTS = inetdayu inetdayt inetechu inetecht MACHINE_TESTS = double1 double2 fmtspcl intformat -MPFR_TESTS = mpfrnr mpfrnegzero mpfrrnd mpfrieee mpfrexprange \ - mpfrsort mpfrbigint +MPFR_TESTS = mpfrnr mpfrnegzero mpfrrem mpfrrnd mpfrieee mpfrexprange \ + mpfrsort mpfrsqrt mpfrbigint LOCALE_CHARSET_TESTS = \ asort asorti backbigs1 backsmalls1 backsmalls2 \ @@ -1748,6 +1752,16 @@ mpfrbigint: @$(AWK) -M -f "$(srcdir)"/$@.awk > _$@ 2>&1 @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +mpfrsqrt: + @echo $@ + @$(AWK) -M -f "$(srcdir)"/$@.awk > _$@ 2>&1 + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + +mpfrrem: + @echo $@ + @$(AWK) -M -f "$(srcdir)"/$@.awk > _$@ 2>&1 + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + jarebug:: @echo $@ @"$(srcdir)"/$@.sh "$(AWKPROG)" "$(srcdir)"/$@.awk "$(srcdir)"/$@.in "_$@" diff --git a/test/Makefile.in b/test/Makefile.in index 449ff46b..f3b537f3 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -775,10 +775,14 @@ EXTRA_DIST = \ mpfrnr.awk \ mpfrnr.in \ mpfrnr.ok \ + mpfrrem.awk \ + mpfrrem.ok \ mpfrrnd.awk \ mpfrrnd.ok \ mpfrsort.awk \ mpfrsort.ok \ + mpfrsqrt.awk \ + mpfrsqrt.ok \ mtchi18n.awk \ mtchi18n.in \ mtchi18n.ok \ @@ -1266,8 +1270,8 @@ GAWK_EXT_TESTS = \ EXTRA_TESTS = inftest regtest INET_TESTS = inetdayu inetdayt inetechu inetecht MACHINE_TESTS = double1 double2 fmtspcl intformat -MPFR_TESTS = mpfrnr mpfrnegzero mpfrrnd mpfrieee mpfrexprange \ - mpfrsort mpfrbigint +MPFR_TESTS = mpfrnr mpfrnegzero mpfrrem mpfrrnd mpfrieee mpfrexprange \ + mpfrsort mpfrsqrt mpfrbigint LOCALE_CHARSET_TESTS = \ asort asorti backbigs1 backsmalls1 backsmalls2 \ @@ -2172,6 +2176,16 @@ mpfrbigint: @$(AWK) -M -f "$(srcdir)"/$@.awk > _$@ 2>&1 @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +mpfrsqrt: + @echo $@ + @$(AWK) -M -f "$(srcdir)"/$@.awk > _$@ 2>&1 + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + +mpfrrem: + @echo $@ + @$(AWK) -M -f "$(srcdir)"/$@.awk > _$@ 2>&1 + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + jarebug:: @echo $@ @"$(srcdir)"/$@.sh "$(AWKPROG)" "$(srcdir)"/$@.awk "$(srcdir)"/$@.in "_$@" diff --git a/test/badargs.ok b/test/badargs.ok index 1be81ec3..8d34be1f 100644 --- a/test/badargs.ok +++ b/test/badargs.ok @@ -18,9 +18,9 @@ Short options: GNU long options: (extensions) -i includefile --include=includefile -l library --load=library -L [fatal] --lint[=fatal] - -n --non-decimal-data -M --bignum -N --use-lc-numeric + -n --non-decimal-data -o[file] --pretty-print[=file] -O --optimize -p[file] --profile[=file] diff --git a/test/mpfrrem.awk b/test/mpfrrem.awk new file mode 100644 index 00000000..fd8bc4d5 --- /dev/null +++ b/test/mpfrrem.awk @@ -0,0 +1,6 @@ +BEGIN { + print "15 % 7 =", 15 % 7 + print "15 % -7 =", 15 % -7 + print "-15 % 7 =", -15 % 7 + print "-15 % -7 =", -15 % -7 +} diff --git a/test/mpfrrem.ok b/test/mpfrrem.ok new file mode 100644 index 00000000..91010457 --- /dev/null +++ b/test/mpfrrem.ok @@ -0,0 +1,4 @@ +15 % 7 = 1 +15 % -7 = 1 +-15 % 7 = -1 +-15 % -7 = -1 diff --git a/test/mpfrsqrt.awk b/test/mpfrsqrt.awk new file mode 100644 index 00000000..23a15c92 --- /dev/null +++ b/test/mpfrsqrt.awk @@ -0,0 +1,82 @@ +# Date: Sat, 02 Aug 2014 12:27:00 -0400 +# To: bug-gawk@gnu.org +# From: Katherine Wasserman <katie@wass.net> +# Message-ID: <E1XDc9F-0007BX-O1@eggs.gnu.org> +# Subject: [bug-gawk] GAWK 4.1 SQRT() bug +# +# In version 4.1.60 of GAWK the sqrt() function does not work correctly on bignums. +# Here's a demo of the problem along with, a function that does work correctly. +# +# Running this program (sqrt-bug.awk): +# -------------------------------------------------------------------- +BEGIN { +a=11111111111111111111111111111111111111111111111111111111111 +print sqrt(a^2) +#print sq_root(a^2) + +# ADR: Added for gawk-4.1-stable which doesn't have built-in div() function +if (PROCINFO["version"] < "4.1.60") + print sq_root2(a^2) +else + print sq_root(a^2) +} + + +function sq_root(x, temp,r,z) +{ temp=substr(x,1,length(x)/2) + 0 # a good first guess + z=0 + while (abs(z-temp)>1) + { z=temp + div(x,temp,r) + temp=r["quotient"] + temp + div(temp,2,r) + temp=r["quotient"] + } + return temp +} + +function sq_root2(x, temp,r,z) +{ temp=substr(x,1,length(x)/2) + 0 # a good first guess + z=0 + while (abs(z-temp)>1) + { z=temp + awk_div(x,temp,r) + temp=r["quotient"] + temp + awk_div(temp,2,r) + temp=r["quotient"] + } + return temp +} + +function abs(x) +{ return (x<0 ? -x : x) +} +# +# -------------------------------------------------------------------- +# gawk -M -f sqrt-bug.awk +# +# results in: +# 11111111111111111261130863809439559987542611609749437808640 +# 11111111111111111111111111111111111111111111111111111111111 +# +# Thanks, +# Katie +# + +# div --- do integer division + +function awk_div(numerator, denominator, result, i, save_PREC) +{ + save_PREC = PREC + PREC = 400 # good enough for this test + + split("", result) + + numerator = int(numerator) + denominator = int(denominator) + result["quotient"] = int(numerator / denominator) + result["remainder"] = int(numerator % denominator) + + PREC = save_PREC + return 0.0 +} diff --git a/test/mpfrsqrt.ok b/test/mpfrsqrt.ok new file mode 100644 index 00000000..16217c78 --- /dev/null +++ b/test/mpfrsqrt.ok @@ -0,0 +1,2 @@ +11111111111111111111111111111111111111111111111111111111111 +11111111111111111111111111111111111111111111111111111111111 diff --git a/test/printhuge.awk b/test/printhuge.awk index 4d4fb7d4..1de27ecc 100644 --- a/test/printhuge.awk +++ b/test/printhuge.awk @@ -1,3 +1,3 @@ BEGIN { - printf("%c", sprintf("%c", (0xffffff00+255))) + printf("%c\n", sprintf("%c", (0xffffff00+255))) } diff --git a/test/printhuge.ok b/test/printhuge.ok index ce542efa..29e181eb 100644 --- a/test/printhuge.ok +++ b/test/printhuge.ok @@ -1 +1 @@ -ÿ
\ No newline at end of file +ÿ |