summaryrefslogtreecommitdiff
path: root/Test
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2000-11-15 20:19:18 +0000
committer <>2013-04-02 19:12:58 +0000
commit5439ab7459283bf61a0256c3a20df164c780ef6c (patch)
treeb44434fc37619db54e956a868b9d99972357d0d4 /Test
downloadbc-tarball-5439ab7459283bf61a0256c3a20df164c780ef6c.tar.gz
Imported from /home/lorry/working-area/delta_bc-tarball/bc-1.06.tar.gz.bc-1.06
Diffstat (limited to 'Test')
-rw-r--r--Test/BUG.bc40
-rw-r--r--Test/array.b14
-rw-r--r--Test/arrayp.b30
-rw-r--r--Test/aryprm.b16
-rw-r--r--Test/atan.b5
-rw-r--r--Test/checklib.b109
-rw-r--r--Test/div.b8
-rw-r--r--Test/exp.b3
-rw-r--r--Test/fact.b12
-rw-r--r--Test/jn.b6
-rw-r--r--Test/ln.b4
-rw-r--r--Test/mul.b13
-rw-r--r--Test/raise.b7
-rw-r--r--Test/signum87
-rw-r--r--Test/sine.b5
-rw-r--r--Test/sqrt.b13
-rw-r--r--Test/sqrt1.b13
-rw-r--r--Test/sqrt2.b10
-rw-r--r--Test/testfn.b47
-rwxr-xr-xTest/timetest16
20 files changed, 458 insertions, 0 deletions
diff --git a/Test/BUG.bc b/Test/BUG.bc
new file mode 100644
index 0000000..254eefe
--- /dev/null
+++ b/Test/BUG.bc
@@ -0,0 +1,40 @@
+/* <--- bug.bc ---><--- bug.bc ---><--- bug.bc ---><--- bug.bc ---> */
+
+/*
+ * See the file "signum" for a description and reference for this
+ * program.
+ *
+ * THIS BUG IS *NOT* IN GNU BC!!!
+ *
+ */
+
+obase=16
+ibase=16
+x=1A8F5C99605AE52 /* dividend */
+y=BB0B404 /* divisor */
+q=245A07AD /* (correct) quotient */
+r=147EB9E /* (correct) remainder */
+"Base 16
+"
+"x = "; x /* output numbers just to be sure... */
+"y = "; y
+"quo = "; q
+"rem = "; r
+"x/y = "; x/y /* watch this result! */
+"x%y = "; x%y /* watch this result! */
+"y*q+r= "; y*q+r /* check quotient & remainder */
+/*
+ * Do the same thing in base 10:
+ */
+"
+Base 10
+"
+ibase=A
+obase=10
+"x = "; x /* output numbers just to be sure... */
+"y = "; y
+"q = "; q
+"r = "; r
+"x/y = "; x/y /* watch this result! */
+"x%y = "; x%y /* watch this result! */
+"y*q+r= "; y*q+r /* check quotient & remainder */
diff --git a/Test/array.b b/Test/array.b
new file mode 100644
index 0000000..a0341ec
--- /dev/null
+++ b/Test/array.b
@@ -0,0 +1,14 @@
+"This tests arrays!
+"
+define p(x,y) {
+ auto i;
+ for (i=x; i<y; i++) a[i];
+}
+
+for (i=0; i<10; i++) a[i] = i;
+j = p(0,10);
+
+for (i=1000; i<1030; i++) a[i] = i;
+j = p(1000,1030);
+j = p(0,10);
+
diff --git a/Test/arrayp.b b/Test/arrayp.b
new file mode 100644
index 0000000..3f3ca50
--- /dev/null
+++ b/Test/arrayp.b
@@ -0,0 +1,30 @@
+"This tests arrays!
+"
+define p(a[],x,y) {
+ auto i;
+ for (i=x; i<y; i++) a[i];
+}
+
+define m(a[],x,y) {
+ auto i;
+ for (i=x; i<y; i++) a[i] = i;
+}
+
+define m1(*a[],x,y) {
+ auto i;
+ print "m1\n"
+ for (i=x; i<y; i++) a[i] = i;
+}
+
+for (i=0; i<10; i++) a[i] = i;
+j = p(a[],0,10);
+
+j = m(b[],0,10);
+j = p(b[],0,10);
+
+print "---\n";
+j = m1(b[],0,10);
+j = p(b[],0,10);
+
+quit
+
diff --git a/Test/aryprm.b b/Test/aryprm.b
new file mode 100644
index 0000000..9d3f95b
--- /dev/null
+++ b/Test/aryprm.b
@@ -0,0 +1,16 @@
+define p ( x[] ) {
+ auto i;
+ for (i=0; i<10; i++) x[i];
+}
+
+define m ( x[] ) {
+ auto i;
+ for (i=0; i<10; i++) x[i] *= 2;
+}
+
+scale = 20;
+for (i=0; i<10; i++) a[i] = sqrt(i);
+
+p(a[]);
+m(a[]);
+p(a[]);
diff --git a/Test/atan.b b/Test/atan.b
new file mode 100644
index 0000000..e742279
--- /dev/null
+++ b/Test/atan.b
@@ -0,0 +1,5 @@
+for (a=0; a<1000; a+=2) x=a(a)
+x
+for (a=0; a<2; a+=.01) x=a(a)
+x
+quit
diff --git a/Test/checklib.b b/Test/checklib.b
new file mode 100644
index 0000000..44c1fac
--- /dev/null
+++ b/Test/checklib.b
@@ -0,0 +1,109 @@
+define t (x,y,d,s,t) {
+ auto u, v, w, i, b, c;
+
+ if (s >= t) {
+ "Bad Scales. Try again.
+"; return;
+ }
+
+ for (i = x; i < y; i += d) {
+ scale = s;
+ u = f(i);
+ scale = t;
+ v = f(i);
+ scale = s;
+ w = v / 1;
+ b += 1;
+ if (u != w) {
+ c += 1;
+"
+Failed:
+"
+ " index = "; i;
+ " val1 = "; u;
+ " val2 = "; v;
+"
+"
+ }
+ }
+
+"
+Total tests: "; b;
+"
+Total failures: "; c;
+"
+Percent failed: "; scale = 2; c*100/b;
+
+}
+
+/*
+ b = begining scale value,
+ l = limit scale value,
+ i = increment scale value.
+
+ if b is set to a non-zero value before this file is executed,
+ b, l and i are not reset.
+*/
+
+if (b == 0) { b = 10; l = 61; i = 10; }
+
+"
+Checking e(x)"
+define f(x) {
+ return (e(x))
+}
+for (s=10; s<l; s=s+i) {
+"
+scale = "; s
+j = t(0,200,1,s,s+4)
+}
+
+"
+Checking l(x)"
+define f(x) {
+ return (l(x))
+}
+for (s=10; s<l; s=s+i) {
+"
+scale = "; s
+j = t(1,10000,25,s,s+4)
+}
+
+"
+Checking s(x)"
+define f(x) {
+ return (s(x))
+}
+for (s=10; s<l; s=s+i) {
+"
+scale = "; s
+j = t(0,8*a(1),.01,s,s+4)
+}
+
+"
+Checking a(x)"
+define f(x) {
+ return (a(x))
+}
+for (s=10; s<l; s=s+i) {
+"
+scale = "; s
+j = t(-1000,1000,10,s,s+4)
+}
+
+"
+Checking j(n,x)"
+define f(x) {
+ return (j(n,x))
+}
+for (s=10; s<l; s=s+i) {
+"
+n=0, scale = "; s
+n=0
+j = t(0,30,.1,s,s+4)
+"
+n=1, scale = "; s
+n=1
+j = t(0,30,.1,s,s+4)
+}
+
diff --git a/Test/div.b b/Test/div.b
new file mode 100644
index 0000000..3c7d377
--- /dev/null
+++ b/Test/div.b
@@ -0,0 +1,8 @@
+scale = 20
+a=2/3
+for (i=0; i<1000; i++) {
+ for (j=1; j<100; j++) b=a/j
+}
+b
+quit
+
diff --git a/Test/exp.b b/Test/exp.b
new file mode 100644
index 0000000..92c482c
--- /dev/null
+++ b/Test/exp.b
@@ -0,0 +1,3 @@
+for (a=0; a<180; a+=.4) x=e(a)
+x
+quit
diff --git a/Test/fact.b b/Test/fact.b
new file mode 100644
index 0000000..995a26d
--- /dev/null
+++ b/Test/fact.b
@@ -0,0 +1,12 @@
+define f (x) {
+
+ if (x<=1) return(1)
+ return (f(x-1)*x)
+}
+
+for (a=1; a<600; a++) b=f(a)
+"
+"
+"b=";b
+quit
+
diff --git a/Test/jn.b b/Test/jn.b
new file mode 100644
index 0000000..a4e0624
--- /dev/null
+++ b/Test/jn.b
@@ -0,0 +1,6 @@
+scale = 50
+for (a=0; a<=100; a += 20) {
+ for (b=0; b<=300; b += 20) x=j(a,b)
+ x
+}
+quit
diff --git a/Test/ln.b b/Test/ln.b
new file mode 100644
index 0000000..cd00232
--- /dev/null
+++ b/Test/ln.b
@@ -0,0 +1,4 @@
+scale = 60
+for (a=1; a<100000000000000000000000000000000000000; a = a*2) x=l(a)
+x
+quit
diff --git a/Test/mul.b b/Test/mul.b
new file mode 100644
index 0000000..722086f
--- /dev/null
+++ b/Test/mul.b
@@ -0,0 +1,13 @@
+scale = 20
+for (i=0; i<10000; i++) {
+ for (j=1; j<100; j++) b=i*j
+}
+b
+for (i=0; i<10000; i++) {
+ for (j=1000000000000000000000000000000000000000000000000000000000000000000; \
+ j<1000000000000000000000000000000000000000000000000000000000000000100; \
+ j++) b=i*j
+}
+b
+quit
+
diff --git a/Test/raise.b b/Test/raise.b
new file mode 100644
index 0000000..ec6929d
--- /dev/null
+++ b/Test/raise.b
@@ -0,0 +1,7 @@
+for (i=0; i<1000; i++) a = 2^i;
+a
+for (i=3000; i<3100; i++) a = 3^i;
+a
+for (i=200; i<220; i++) a = (4^100)^i;
+a
+quit
diff --git a/Test/signum b/Test/signum
new file mode 100644
index 0000000..9e27d2d
--- /dev/null
+++ b/Test/signum
@@ -0,0 +1,87 @@
+
+
+
+/* From gnu@cygnus.com Wed Jul 14 13:46:44 1993
+Return-Path: <gnu@cygnus.com>
+To: phil@cs.wwu.edu, gnu@cygnus.com
+Subject: bc/dc - no rest for the wicked
+Date: Tue, 06 Jul 93 19:12:40 -0700
+From: gnu@cygnus.com
+
+GNU bc 1.02 passes all these tests. Can you add the test to the distribution?
+Putting it into a DejaGnu test case for GNU bc would be a great thing, too.
+(I haven't seen the Signum paper, maybe you can dig it out.)
+
+ John Gilmore
+ Cygnus Support
+
+------- Forwarded Message
+
+Date: Tue, 6 Jul 93 08:45:48 PDT
+From: uunet!Eng.Sun.COM!David.Hough@uunet.UU.NET (David Hough)
+Message-Id: <9307061545.AA14477@dgh.Eng.Sun.COM>
+To: numeric-interest@validgh.com
+Subject: bc/dc - no rest for the wicked
+
+Steve Sommars sent me a bc script which reproduces ALL the test cases from
+Dittmer's paper. Neither SunOS 5.2 on SPARC nor 5.1 on x86 come out clean.
+Anybody else who has fixed all the bugs would be justified in
+bragging about it here. */
+
+
+/*Ingo Dittmer, ACM Signum, April 1993, page 8-11*/
+define g(x,y,z){
+ auto a
+ a=x%y
+ if(a!=z){
+"
+x=";x
+ "y=";y
+ "Should be ";z
+ "was ";a
+ }
+}
+
+/*Table 1*/
+g=g(53894380494284,9980035577,2188378484)
+g=g(47907874973121,9980035577,3704203521)
+g=g(76850276401922,9980035577,4002459022)
+g=g(85830854846664,9980035577,2548884464)
+g=g(43915353970066,9980035577,3197431266)
+g=g(35930746212825,9980035577,2618135625)
+g=g(51900604524715,9980035577,4419524315)
+g=g(87827018005068,9980035577,2704927468)
+g=g(57887902441764,9980035577,3696095164)
+g=g(96810941031110,9980035577,4595934210)
+
+/*Table 2*/
+g=g(86833646827370,9980035577,7337307470)
+g=g(77850880592435,9980035577,6603091835)
+g=g(84836601050323,9980035577,6298645823)
+g=g(85835110016211,9980035577,6804054011)
+g=g(94817143459192,9980035577,6805477692)
+g=g(94818870293481,9980035577,8532311981)
+g=g(91823235571154,9980035577,6908262754)
+g=g(59885451951796,9980035577,5238489796)
+g=g(80844460893239,9980035577,6172719539)
+g=g(67869195894693,9980035577,4953971093)
+g=g(95813990985202,9980035577,5649446002)
+
+/*Skip Table 3, duplicate of line 1, table 1*/
+
+/*Table 4*/
+g=g(28420950579078013018256253301,17987947258,16619542243)
+g=g(12015118977201790601658257234,16687885701,8697335297)
+g=g(14349070374946789715188912007,13712994561,3605141129)
+g=g(61984050238512905451986475027,13337935089,5296182558)
+g=g(86189707791214681859449918641,17837971389,14435206830)
+g=g(66747908181102582528134773954,19462997965,8615839889)
+
+/*Table 6*/
+g=g(4999253,9998,253)
+g=g(8996373,9995,873)
+
+
+/* Added by Phil Nelson..... */
+"end of tests
+"
diff --git a/Test/sine.b b/Test/sine.b
new file mode 100644
index 0000000..18c4b57
--- /dev/null
+++ b/Test/sine.b
@@ -0,0 +1,5 @@
+for (i=0; i<8*a(1); i=i+.01) x=s(i)
+x
+for (i=i; i<16*a(1); i=i+.01) x=s(i+.1234123412341234)
+x
+quit
diff --git a/Test/sqrt.b b/Test/sqrt.b
new file mode 100644
index 0000000..3fb548c
--- /dev/null
+++ b/Test/sqrt.b
@@ -0,0 +1,13 @@
+scale = 5
+for (a=1; a<500; a++) r=sqrt(a)
+r
+scale = 10
+for (a=1; a<500; a++) r=sqrt(a)
+r
+scale = 25
+for (a=1; a<500; a++) r=sqrt(a)
+r
+scale = 40
+for (a=1; a<500; a++) r=sqrt(a)
+r
+quit
diff --git a/Test/sqrt1.b b/Test/sqrt1.b
new file mode 100644
index 0000000..c3ca269
--- /dev/null
+++ b/Test/sqrt1.b
@@ -0,0 +1,13 @@
+for (j=0; j<10; j++) {
+ a = .9;
+ b = .9+j;
+ scale = 2;
+ for (i=0; i<90; i++) {
+ scale += 1;
+ a /= 10;
+ b += a;
+ x = sqrt(b);
+ }
+ x;
+}
+quit
diff --git a/Test/sqrt2.b b/Test/sqrt2.b
new file mode 100644
index 0000000..bd0eaad
--- /dev/null
+++ b/Test/sqrt2.b
@@ -0,0 +1,10 @@
+scale = 20
+for (a=1; a<5000; a += 1) r=sqrt(a)
+r
+for (a=1; a<50000; a += 100) r=sqrt(a)
+r
+for (a=1; a<500000; a+=1000) r=sqrt(a)
+r
+for (a=1; a<5000000; a+=10000) r=sqrt(a)
+r
+quit
diff --git a/Test/testfn.b b/Test/testfn.b
new file mode 100644
index 0000000..7578fc5
--- /dev/null
+++ b/Test/testfn.b
@@ -0,0 +1,47 @@
+/* This function "t" tests the function "f" to see if computing at
+ two different scales has much effect on the accuracy.
+ test from f(x) to f(y) incrementing the index by d. f(i) is
+ computed at two scales, scale s and then scale t, where t>s.
+ the result from scale t is divided by 1 at scale s and the
+ results are compared. If they are different, the function is
+ said to have failed. It will then print out the value of i
+ (called index) and the two original values val1 (scale s) and
+ val2 (scale t) */
+
+define t (x,y,d,s,t) {
+ auto u, v, w, i, b, c;
+
+ if (s >= t) {
+ "Bad Scales. Try again.
+"; return;
+ }
+
+ for (i = x; i < y; i += d) {
+ scale = s;
+ u = f(i);
+ scale = t;
+ v = f(i);
+ scale = s;
+ w = v / 1;
+ b += 1;
+ if (u != w) {
+ c += 1;
+"
+Failed:
+"
+ " index = "; i;
+ " val1 = "; u;
+ " val2 = "; v;
+"
+"
+ }
+ }
+
+"
+Total tests: "; b;
+"
+Total failures: "; c;
+"
+Percent failed: "; scale = 2; c*100/b;
+
+}
diff --git a/Test/timetest b/Test/timetest
new file mode 100755
index 0000000..1a4d0ea
--- /dev/null
+++ b/Test/timetest
@@ -0,0 +1,16 @@
+#!/bin/sh
+#
+# Time the functions.
+#
+SYSBC=/usr/bin/bc
+if [ x$BC = x ] ; then
+ BC=../bc/bc
+fi
+for file in exp.b ln.b sine.b atan.b jn.b mul.b div.b raise.b sqrt.b
+do
+for prog in $BC $SYSBC $OTHERBC
+do
+echo Timing $file with $prog
+time $prog -l $file
+done
+done