summaryrefslogtreecommitdiffstats
path: root/contrib/bc/Test
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/bc/Test')
-rw-r--r--contrib/bc/Test/BUG.bc40
-rw-r--r--contrib/bc/Test/TESTS.bc565
-rw-r--r--contrib/bc/Test/array.b14
-rw-r--r--contrib/bc/Test/arrayp.b30
-rw-r--r--contrib/bc/Test/aryprm.b16
-rw-r--r--contrib/bc/Test/atan.b5
-rw-r--r--contrib/bc/Test/checklib.b109
-rw-r--r--contrib/bc/Test/div.b8
-rw-r--r--contrib/bc/Test/exp.b3
-rw-r--r--contrib/bc/Test/fact.b13
-rw-r--r--contrib/bc/Test/jn.b6
-rw-r--r--contrib/bc/Test/ln.b3
-rw-r--r--contrib/bc/Test/mul.b7
-rw-r--r--contrib/bc/Test/raise.b3
-rw-r--r--contrib/bc/Test/signum87
-rw-r--r--contrib/bc/Test/sine.b5
-rw-r--r--contrib/bc/Test/sqrt.b13
-rw-r--r--contrib/bc/Test/sqrt1.b13
-rw-r--r--contrib/bc/Test/sqrt2.b10
-rw-r--r--contrib/bc/Test/testfn.b47
-rwxr-xr-xcontrib/bc/Test/timetest14
21 files changed, 1011 insertions, 0 deletions
diff --git a/contrib/bc/Test/BUG.bc b/contrib/bc/Test/BUG.bc
new file mode 100644
index 0000000..254eefe
--- /dev/null
+++ b/contrib/bc/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/contrib/bc/Test/TESTS.bc b/contrib/bc/Test/TESTS.bc
new file mode 100644
index 0000000..ec42172
--- /dev/null
+++ b/contrib/bc/Test/TESTS.bc
@@ -0,0 +1,565 @@
+From phil@cs.wwu.edu Mon Mar 20 23:13:22 1995
+Date: Mon, 20 Mar 1995 23:12:17 -0800
+From: Phil Nelson <phil@cs.wwu.edu>
+To: phil@steelhead.cs.wwu.edu
+Subject: [jhn@ironwood.cray.com: XPG4 bc(1) failures]
+
+From: jhn@ironwood.cray.com (James Nordby)
+Subject: XPG4 bc(1) failures
+To: phil@cs.wwu.edu
+Date: Fri, 17 Mar 1995 12:14:13 -0600 (CST)
+X-Mailer: ELM [version 2.4 PL24-CRI-b]
+Mime-Version: 1.0
+Content-Type: text/plain; charset=US-ASCII
+Content-Transfer-Encoding: 7bit
+Content-Length: 14277
+
+
+Phil,
+
+Here are the test results I'm getting from the XPG4 test suite,
+with some explanation and fixes so far. Let me know what you
+think...
+
+Thanks much,
+Jim Nordby (jhn@cray.com)
+
+
+-------- bc 08:38:34 --------
+
+Assertion #20 (A): bc reads text files
+Expected exit code = 0; Received 139
+Standard output isn't the same as file 'bc_eso_20_1'
+diff of "out.stdout" and "bc_eso_20_1":
+*** out.stdout Fri Mar 17 08:39:22 1995
+--- bc_eso_20_1 Fri Mar 17 08:39:22 1995
+***************
+*** 0 ****
+--- 1,31 ----
++ 11111111111111111111111111111111111111111111111111111111111111111111
++ 11111111111111111111111111111111111111111111111111111111111111111111
++ 11111111111111111111111111111111111111111111111111111111111111111111
++ 11111111111111111111111111111111111111111111111111111111111111111111
++ 11111111111111111111111111111111111111111111111111111111111111111111
++ 11111111111111111111111111111111111111111111111111111111111111111111
++ 11111111111111111111111111111111111111111111111111111111111111111111
++ 11111111111111111111111111111111111111111111111111111111111111111111
++ 11111111111111111111111111111111111111111111111111111111111111111111
++ 11111111111111111111111111111111111111111111111111111111111111111111
++ 11111111111111111111111111111111111111111111111111111111111111111111
++ 11111111111111111111111111111111111111111111111111111111111111111111
++ 11111111111111111111111111111111111111111111111111111111111111111111
++ 11111111111111111111111111111111111111111111111111111111111111111111
++ 11111111111111111111111111111111111111111111111111111111111111111111
++ 11111111111111111111111111111111111111111111111111111111111111111111
++ 11111111111111111111111111111111111111111111111111111111111111111111
++ 11111111111111111111111111111111111111111111111111111111111111111111
++ 11111111111111111111111111111111111111111111111111111111111111111111
++ 11111111111111111111111111111111111111111111111111111111111111111111
++ 11111111111111111111111111111111111111111111111111111111111111111111
++ 11111111111111111111111111111111111111111111111111111111111111111111
++ 11111111111111111111111111111111111111111111111111111111111111111111
++ 11111111111111111111111111111111111111111111111111111111111111111111
++ 11111111111111111111111111111111111111111111111111111111111111111111
++ 11111111111111111111111111111111111111111111111111111111111111111111
++ 11111111111111111111111111111111111111111111111111111111111111111111
++ 11111111111111111111111111111111111111111111111111111111111111111111
++ 11111111111111111111111111111111111111111111111111111111111111111111
++ 11111111111111111111111111111111111111111111111111111111111111111111
++ 1111111
+Assertion Result: FAIL
+
+I couldn't reproduce this problem; when I rebuilt your bc and
+ran it, I got a different problem with printing out a large
+number. The XPG4 tests expected lines to be 70 characters
+long, INCLUDING the newline (this comes from the POSIX definition
+of a line). To fix it, I changed util.c like so:
+
+*** util.c Thu Mar 16 10:47:36 1995
+--- util.c.old Thu Mar 16 10:50:10 1995
+***************
+*** 309,323 ****
+ else
+ {
+ out_col++;
+- #ifdef _CRAY
+- /*
+- * XPG4 considers a line to include the <newline>;
+- * therefore we want 68 numerals, <backslash>, <newline>
+- */
+- if (out_col == 69)
+- #else
+ if (out_col == 70)
+- #endif
+ {
+ putchar ('\\');
+ putchar ('\n');
+--- 309,315 ----
+
+
+
+
+
+
+Assertion #42 (A): check reserved words
+Standard error isn't empty
+Contents of out.stderr:
+(standard_in) 6: syntax error
+(standard_in) 15: syntax error
+Standard output isn't the same as file 'bc_eso_42_1'
+diff of "out.stdout" and "bc_eso_42_1":
+*** out.stdout Fri Mar 17 08:39:43 1995
+--- bc_eso_42_1 Fri Mar 17 08:39:43 1995
+***************
+*** 1,2 ****
+--- 1,3 ----
+ 2
+ 1
++ 0
+Assertion Result: FAIL
+
+This one is debatable, based on the grammar in the POSIX manual.
+Here's the input file:
+
+cat << \VSC-EOF > input
+define a() {
+ auto b;
+ for ( b = 0; b < 10; b++ ) {
+ b;
+ if ( b == 1 )
+ break;
+ }
+ return ( 5 ) ;
+}
+ibase = 10;
+length ( obase );
+scale = 0;
+sqrt(1);
+while ( a() != 5 )
+VSC-EOF
+
+They want these constructs to be accepted:
+
+
+if (b == 1)
+ whatever;
+for (x = 0; x < 10; x++)
+ whatever;
+while (x < 10)
+ whatever;
+
+rather than just
+
+if (b == 1) {
+ whatever
+}
+etc.
+
+The grammar as it's currently worded requires a '{' before hitting
+a NEWLINE for these constructs. It's easy enough to change in bc.y
+(see below), but if I do change it, it still barfs on the last
+line of the file ( 'while (a() != 5)' ). Since the while lacks
+a body, it gives a syntax error; they're expecting a '0' to be
+returned. The grammar could be changed to support this, but is
+it a good idea?
+
+
+*** bc.y Thu Mar 16 10:47:20 1995
+--- bc.y.old Thu Mar 16 10:50:11 1995
+***************
+*** 142,150 ****
+ | error statement
+ { $$ = $2; }
+ ;
+- allow_newlines : /* empty */
+- | NEWLINE allow_newlines
+- ;
+ statement : Warranty
+ { warranty (""); }
+ | Limits
+--- 142,147 ----
+***************
+*** 231,237 ****
+ sprintf (genstr, "pJ%1d:N%1d:", $4, $7);
+ generate (genstr);
+ }
+! allow_newlines statement
+ {
+ sprintf (genstr, "J%1d:N%1d:",
+ continue_label, break_label);
+--- 228,234 ----
+ sprintf (genstr, "pJ%1d:N%1d:", $4, $7);
+ generate (genstr);
+ }
+! statement
+ {
+ sprintf (genstr, "J%1d:N%1d:",
+ continue_label, break_label);
+***************
+*** 246,252 ****
+ sprintf (genstr, "Z%1d:", if_label);
+ generate (genstr);
+ }
+! allow_newlines statement opt_else
+ {
+ sprintf (genstr, "N%1d:", if_label);
+ generate (genstr);
+--- 243,249 ----
+ sprintf (genstr, "Z%1d:", if_label);
+ generate (genstr);
+ }
+! statement opt_else
+ {
+ sprintf (genstr, "N%1d:", if_label);
+ generate (genstr);
+***************
+*** 265,271 ****
+ sprintf (genstr, "Z%1d:", break_label);
+ generate (genstr);
+ }
+! ')' allow_newlines statement
+ {
+ sprintf (genstr, "J%1d:N%1d:", $1, break_label);
+ generate (genstr);
+--- 262,268 ----
+ sprintf (genstr, "Z%1d:", break_label);
+ generate (genstr);
+ }
+! ')' statement
+ {
+ sprintf (genstr, "J%1d:N%1d:", $1, break_label);
+ generate (genstr);
+
+
+
+
+Assertion #49 (A): check strings
+Expected exit code = 0; Received 1
+Standard error isn't empty
+Contents of out.stderr:
+File (NULL) is unavailable.
+Standard output isn't the same as file 'bc_eso_49_1'
+diff of "out.stdout" and "bc_eso_49_1":
+cmd-1794 diff: Missing newline at end of file 'bc_eso_49_1'.
+*** out.stdout Fri Mar 17 08:40:01 1995
+--- bc_eso_49_1 Fri Mar 17 08:40:01 1995
+***************
+*** 0 ****
+--- 1 ----
++ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+*LINE CONTINUATION -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+*LINE CONTINUATION -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+Assertion Result: FAIL
+
+This gist of this is that the standard expects numbers to
+be truncated to 70 characters, but STRINGS should not.
+My changes to fix this are:
+
+
+*** execute.c Thu Mar 16 13:06:39 1995
+--- execute.c.old Thu Mar 16 10:50:09 1995
+***************
+*** 208,218 ****
+ case 'O' : /* Write a string to the output with processing. */
+ while ((ch = byte(&pc)) != '"')
+ if (ch != '\\')
+- #ifdef _CRAY
+- putchar (ch);
+- #else
+ out_char (ch);
+- #endif
+ else
+ {
+ ch = byte(&pc);
+--- 207,213 ----
+***************
+*** 219,234 ****
+ if (ch == '"') break;
+ switch (ch)
+ {
+- #ifdef _CRAY
+- case 'a': putchar (007); break;
+- case 'b': putchar ('\b'); break;
+- case 'f': putchar ('\f'); break;
+- case 'n': putchar ('\n'); break;
+- case 'q': putchar ('"'); break;
+- case 'r': putchar ('\r'); break;
+- case 't': putchar ('\t'); break;
+- case '\\': putchar ('\\'); break;
+- #else
+ case 'a': out_char (007); break;
+ case 'b': out_char ('\b'); break;
+ case 'f': out_char ('\f'); break;
+--- 214,219 ----
+***************
+*** 237,243 ****
+ case 'r': out_char ('\r'); break;
+ case 't': out_char ('\t'); break;
+ case '\\': out_char ('\\'); break;
+- #endif
+ default: break;
+ }
+ }
+--- 222,227 ----
+***************
+*** 350,360 ****
+ break;
+
+ case 'w' : /* Write a string to the output. */
+- #ifdef _CRAY
+- while ((ch = byte(&pc)) != '"') putchar (ch);
+- #else
+ while ((ch = byte(&pc)) != '"') out_char (ch);
+- #endif
+ if (interactive) fflush (stdout);
+ break;
+
+
+
+
+Assertion #77 (C): output longer than 70 characters
+Standard output isn't the same as file 'bc_eso_77_1'
+diff of "out.stdout" and "bc_eso_77_1":
+*** out.stdout Fri Mar 17 08:41:13 1995
+--- bc_eso_77_1 Fri Mar 17 08:41:13 1995
+***************
+*** 1,2 ****
+! 3.3333333333333333333333333333333333333333333333333333333333333333333
+! 33333333333333333333333333333333
+--- 1,2 ----
+! 3.333333333333333333333333333333333333333333333333333333333333333333
+! 333333333333333333333333333333333
+Assertion Result: FAIL
+
+Same as assertion #20 above...
+
+
+
+
+Assertion #92 (A): check %
+Standard output isn't the same as file 'bc_eso_92_1'
+diff of "out.stdout" and "bc_eso_92_1":
+*** out.stdout Fri Mar 17 08:41:33 1995
+--- bc_eso_92_1 Fri Mar 17 08:41:33 1995
+***************
+*** 4,8 ****
+ 4
+ 15
+ 1
+! 0
+! 0
+--- 4,8 ----
+ 4
+ 15
+ 1
+! 6
+! 5
+Assertion Result: FAIL
+
+This one is a pain. The failing code looks like this:
+
+scale = 4
+scale ( 5.000000 % 2.0 )
+scale ( 5.00 % 2.0 )
+
+They expect '6' and '5' for output, instead of '0', based on
+the explanation of the modulus operator ("scale of the result
+shall be 'max(scale + scale(b), scale(a)'"), even though the
+result is a 0. I was able to fix this problem by the change
+below:
+
+*** number.c Thu Mar 16 13:15:43 1995
+--- number.c.old Thu Mar 16 10:50:09 1995
+***************
+*** 614,623 ****
+ case 0:
+ /* They are equal! return zero! */
+ diff = copy_num (_zero_);
+- #ifdef _CRAY
+- /* correct the scale here */
+- diff->n_scale = MAX (n1->n_scale, n2->n_scale);
+- #endif
+ break;
+ case 1:
+ /* n2 is less than n1, subtract n2 from n1. */
+
+but this causes another test failure that I haven't looked at.
+
+
+
+
+Assertion #130 (A): functions are call by value
+Standard output isn't the same as file 'bc_eso_130_1'
+diff of "out.stdout" and "bc_eso_130_1":
+*** out.stdout Fri Mar 17 08:42:24 1995
+--- bc_eso_130_1 Fri Mar 17 08:42:24 1995
+***************
+*** 4,10 ****
+ 5
+ 4
+ 0
+! 4
+ 3
+ 3
+ 5
+--- 4,10 ----
+ 5
+ 4
+ 0
+! 5
+ 3
+ 3
+ 5
+Assertion Result: FAIL
+
+Assertion #131 (A): functions are call by value
+Standard output isn't the same as file 'bc_eso_131_1'
+diff of "out.stdout" and "bc_eso_131_1":
+*** out.stdout Fri Mar 17 08:42:28 1995
+--- bc_eso_131_1 Fri Mar 17 08:42:28 1995
+***************
+*** 4,10 ****
+ 5
+ 4
+ 0
+! 4
+ 3
+ 3
+ 5
+--- 4,10 ----
+ 5
+ 4
+ 0
+! 5
+ 3
+ 3
+ 5
+Assertion Result: FAIL
+
+
+Both of these are the 'arrays are passed by value' problem.
+One of the test cases is below:
+
+cat << \VSC-EOF > bc_in_130_1
+a[0] = 3
+a[0]
+define b(a[]) {
+a[0]
+a[0] = 4
+a[0]
+}
+a[0]
+a[0] = 5
+a[0]
+b(a[])
+a[0]
+VSC-EOF
+
+They expect the assignment of a[0] inside the b() function
+to not affect a[0] outside of the function.
+
+
+
+
+
+Assertion #139 (A): check sin
+Standard output isn't the same as file 'bc_eso_139_1'
+diff of "out.stdout" and "bc_eso_139_1":
+*** out.stdout Fri Mar 17 08:42:40 1995
+--- bc_eso_139_1 Fri Mar 17 08:42:39 1995
+***************
+*** 1,5 ****
+ 0
+! 20
+ 1.68294196961579301330
+ 20
+ 1.6829419696
+--- 1,5 ----
+ 0
+! 0
+ 1.68294196961579301330
+ 20
+ 1.6829419696
+Assertion Result: FAIL
+
+Assertion #141 (A): check arctanngent
+Standard output isn't the same as file 'bc_eso_141_1'
+diff of "out.stdout" and "bc_eso_141_1":
+*** out.stdout Fri Mar 17 08:42:44 1995
+--- bc_eso_141_1 Fri Mar 17 08:42:44 1995
+***************
+*** 1,5 ****
+ 0
+! 20
+ 3.14159265358979323844
+ 20
+ 3.1415926532
+--- 1,5 ----
+ 0
+! 0
+ 3.14159265358979323844
+ 20
+ 3.1415926532
+Assertion Result: FAIL
+
+Assertion #142 (A): check log
+Standard output isn't the same as file 'bc_eso_142_1'
+diff of "out.stdout" and "bc_eso_142_1":
+*** out.stdout Fri Mar 17 08:42:47 1995
+--- bc_eso_142_1 Fri Mar 17 08:42:47 1995
+***************
+*** 1,5 ****
+ 0
+! 20
+ 2.30258509299404568401
+ 20
+ 2.3025850929
+--- 1,5 ----
+ 0
+! 0
+ 2.30258509299404568401
+ 20
+ 2.3025850929
+Assertion Result: FAIL
+
+Assertion #144 (A): check bessel
+Standard output isn't the same as file 'bc_eso_144_1'
+diff of "out.stdout" and "bc_eso_144_1":
+*** out.stdout Fri Mar 17 08:42:51 1995
+--- bc_eso_144_1 Fri Mar 17 08:42:51 1995
+***************
+*** 1,5 ****
+ 0
+! 20
+ .57672480775687338720
+ 20
+ .5767248077
+--- 1,5 ----
+ 0
+! 0
+ .57672480775687338720
+ 20
+ .5767248077
+Assertion Result: FAIL
+
+All of these are the same. I'll give you the test case
+for 'sin'; what they're expecting is 0:
+
+scale(s(0))
+
+bc outputs '20' (which is the scale at the time), but the
+interpretation of the standard says that it should be '0',
+since s(0) is 0, and the scale of 0 is 0. I think that
+this interpretation disagrees with one of the previous
+assertions (assertion #92).
+
+/* end of test results */
+
+
+
+--
+Phil Nelson
+e-mail: phil@cs.wwu.edu
+http://www.cs.wwu.edu/~phil
+
+
diff --git a/contrib/bc/Test/array.b b/contrib/bc/Test/array.b
new file mode 100644
index 0000000..a0341ec
--- /dev/null
+++ b/contrib/bc/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/contrib/bc/Test/arrayp.b b/contrib/bc/Test/arrayp.b
new file mode 100644
index 0000000..3f3ca50
--- /dev/null
+++ b/contrib/bc/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/contrib/bc/Test/aryprm.b b/contrib/bc/Test/aryprm.b
new file mode 100644
index 0000000..9d3f95b
--- /dev/null
+++ b/contrib/bc/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/contrib/bc/Test/atan.b b/contrib/bc/Test/atan.b
new file mode 100644
index 0000000..e742279
--- /dev/null
+++ b/contrib/bc/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/contrib/bc/Test/checklib.b b/contrib/bc/Test/checklib.b
new file mode 100644
index 0000000..44c1fac
--- /dev/null
+++ b/contrib/bc/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/contrib/bc/Test/div.b b/contrib/bc/Test/div.b
new file mode 100644
index 0000000..3c7d377
--- /dev/null
+++ b/contrib/bc/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/contrib/bc/Test/exp.b b/contrib/bc/Test/exp.b
new file mode 100644
index 0000000..ed0e536
--- /dev/null
+++ b/contrib/bc/Test/exp.b
@@ -0,0 +1,3 @@
+for (a=0; a<150; a++) x=e(a)
+x
+quit
diff --git a/contrib/bc/Test/fact.b b/contrib/bc/Test/fact.b
new file mode 100644
index 0000000..8d14747
--- /dev/null
+++ b/contrib/bc/Test/fact.b
@@ -0,0 +1,13 @@
+define f (x) {
+
+ if (x<=1) return(1)
+ return (f(x-1)*x)
+}
+
+"Here we go"
+for (a=1; a<100; a++) b+=f(a)/a
+"
+"
+"b=";b
+quit
+
diff --git a/contrib/bc/Test/jn.b b/contrib/bc/Test/jn.b
new file mode 100644
index 0000000..80ac915
--- /dev/null
+++ b/contrib/bc/Test/jn.b
@@ -0,0 +1,6 @@
+scale = 30
+for (a=0; a<5; a=a+2) {
+ for (b=0; b<100; b=b+10) x=j(a,b)
+}
+x
+quit
diff --git a/contrib/bc/Test/ln.b b/contrib/bc/Test/ln.b
new file mode 100644
index 0000000..00a1deb
--- /dev/null
+++ b/contrib/bc/Test/ln.b
@@ -0,0 +1,3 @@
+for (a=1; a<10000000000000000000000000000; a = a*2) x=l(a)
+x
+quit
diff --git a/contrib/bc/Test/mul.b b/contrib/bc/Test/mul.b
new file mode 100644
index 0000000..1970ed1
--- /dev/null
+++ b/contrib/bc/Test/mul.b
@@ -0,0 +1,7 @@
+scale = 20
+for (i=0; i<1000; i++) {
+ for (j=1; j<100; j++) b=i*j
+}
+b
+quit
+
diff --git a/contrib/bc/Test/raise.b b/contrib/bc/Test/raise.b
new file mode 100644
index 0000000..a885815
--- /dev/null
+++ b/contrib/bc/Test/raise.b
@@ -0,0 +1,3 @@
+for (i=0; i<1000; i++) a = 2^i;
+a
+quit
diff --git a/contrib/bc/Test/signum b/contrib/bc/Test/signum
new file mode 100644
index 0000000..9e27d2d
--- /dev/null
+++ b/contrib/bc/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/contrib/bc/Test/sine.b b/contrib/bc/Test/sine.b
new file mode 100644
index 0000000..18c4b57
--- /dev/null
+++ b/contrib/bc/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/contrib/bc/Test/sqrt.b b/contrib/bc/Test/sqrt.b
new file mode 100644
index 0000000..3fb548c
--- /dev/null
+++ b/contrib/bc/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/contrib/bc/Test/sqrt1.b b/contrib/bc/Test/sqrt1.b
new file mode 100644
index 0000000..c3ca269
--- /dev/null
+++ b/contrib/bc/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/contrib/bc/Test/sqrt2.b b/contrib/bc/Test/sqrt2.b
new file mode 100644
index 0000000..bd0eaad
--- /dev/null
+++ b/contrib/bc/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/contrib/bc/Test/testfn.b b/contrib/bc/Test/testfn.b
new file mode 100644
index 0000000..7578fc5
--- /dev/null
+++ b/contrib/bc/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/contrib/bc/Test/timetest b/contrib/bc/Test/timetest
new file mode 100755
index 0000000..90da6ab
--- /dev/null
+++ b/contrib/bc/Test/timetest
@@ -0,0 +1,14 @@
+#!/bin/sh
+#
+# Time the functions.
+#
+BC=../bc
+SYSBC=/usr/bin/bc
+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
+do
+echo Timing $file with $prog
+time $prog -l $file
+done
+done
OpenPOWER on IntegriCloud