summaryrefslogtreecommitdiffstats
path: root/regress/usr.bin/bc
diff options
context:
space:
mode:
authorotto <otto@openbsd.org>2003-09-25 19:40:07 +0000
committerotto <otto@openbsd.org>2003-09-25 19:40:07 +0000
commit72a6d7bd0acbb2f55631aaafc07cb7cd61572af3 (patch)
tree1fc438e60b64a9b69047ea3660b4fce108f685f9 /regress/usr.bin/bc
parentUSD doc for bc(1) using the Caldera license. (diff)
downloadwireguard-openbsd-72a6d7bd0acbb2f55631aaafc07cb7cd61572af3.tar.xz
wireguard-openbsd-72a6d7bd0acbb2f55631aaafc07cb7cd61572af3.zip
A set of regression tests for bc(1).
Diffstat (limited to 'regress/usr.bin/bc')
-rw-r--r--regress/usr.bin/bc/Makefile31
-rw-r--r--regress/usr.bin/bc/t1.in234
-rw-r--r--regress/usr.bin/bc/t1.out63
-rw-r--r--regress/usr.bin/bc/t2.in5
-rw-r--r--regress/usr.bin/bc/t2.out7
-rw-r--r--regress/usr.bin/bc/t3.in4
-rw-r--r--regress/usr.bin/bc/t3.out4
-rw-r--r--regress/usr.bin/bc/t4.in6
-rw-r--r--regress/usr.bin/bc/t4.out18
-rw-r--r--regress/usr.bin/bc/t5.in7
-rw-r--r--regress/usr.bin/bc/t5.out6
-rw-r--r--regress/usr.bin/bc/t6.in3
-rw-r--r--regress/usr.bin/bc/t6.out7
13 files changed, 395 insertions, 0 deletions
diff --git a/regress/usr.bin/bc/Makefile b/regress/usr.bin/bc/Makefile
new file mode 100644
index 00000000000..d2c3919f40d
--- /dev/null
+++ b/regress/usr.bin/bc/Makefile
@@ -0,0 +1,31 @@
+# $OpenBSD: Makefile,v 1.1 2003/09/25 19:40:07 otto Exp $
+
+BC=bc
+
+REGRESS_TARGETS=t1 t2 t3 t4 t5 t6
+
+# .in: input file
+# .out: desired result
+
+# t1: bc.library
+# t2: while loop
+# t3: for loop
+# t4: deep nested while loop
+# t5: function definition and call
+# t6: empty if statement
+
+all: clean ${REGRESS_TARGET}
+
+.SUFFIXES: .in
+
+.in:
+ @echo ${*}
+ @${BC} -d < ${.CURDIR}/${*}.in > ${*}.log
+ @cmp -s ${.CURDIR}/${*}.out ${*}.log || \
+ (echo "XXX ${*} failed" && false)
+
+# Clean all files generated
+clean:
+ rm -f *.log
+
+.include <bsd.regress.mk>
diff --git a/regress/usr.bin/bc/t1.in b/regress/usr.bin/bc/t1.in
new file mode 100644
index 00000000000..e7b878c8654
--- /dev/null
+++ b/regress/usr.bin/bc/t1.in
@@ -0,0 +1,234 @@
+/* $OpenBSD: t1.in,v 1.1 2003/09/25 19:40:07 otto Exp $ */
+
+/*
+ * Copyright (C) Caldera International Inc. 2001-2002.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code and documentation must retain the above
+ * copyright notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed or owned by Caldera
+ * International, Inc.
+ * 4. Neither the name of Caldera International, Inc. nor the names of other
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
+ * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE FOR ANY DIRECT,
+ * INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * @(#)bc.library 5.1 (Berkeley) 4/17/91
+ */
+
+scale = 20
+define e(x){
+ auto a, b, c, d, e, g, t, w, y
+
+ t = scale
+ scale = t + .434*x + 1
+
+ w = 0
+ if(x<0){
+ x = -x
+ w = 1
+ }
+ y = 0
+ while(x>2){
+ x = x/2
+ y = y + 1
+ }
+
+ a=1
+ b=1
+ c=b
+ d=1
+ e=1
+ for(a=1;1==1;a++){
+ b=b*x
+ c=c*a+b
+ d=d*a
+ g = c/d
+ if(g == e){
+ g = g/1
+ while(y--){
+ g = g*g
+ }
+ scale = t
+ if(w==1) return(1/g)
+ return(g/1)
+ }
+ e=g
+ }
+}
+
+define l(x){
+ auto a, b, c, d, e, f, g, u, s, t
+ if(x <=0) return(1-10^scale)
+ t = scale
+
+ f=1
+ scale = scale + scale(x) - length(x) + 1
+ s=scale
+ while(x > 2){
+ s = s + (length(x)-scale(x))/2 + 1
+ if(s>0) scale = s
+ x = sqrt(x)
+ f=f*2
+ }
+ while(x < .5){
+ s = s + (length(x)-scale(x))/2 + 1
+ if(s>0) scale = s
+ x = sqrt(x)
+ f=f*2
+ }
+
+ scale = t + length(f) - scale(f) + 1
+ u = (x-1)/(x+1)
+
+ scale = scale + 1.1*length(t) - 1.1*scale(t)
+ s = u*u
+ b = 2*f
+ c = b
+ d = 1
+ e = 1
+ for(a=3;1==1;a=a+2){
+ b=b*s
+ c=c*a+d*b
+ d=d*a
+ g=c/d
+ if(g==e){
+ scale = t
+ return(u*c/d)
+ }
+ e=g
+ }
+}
+
+define s(x){
+ auto a, b, c, s, t, y, p, n, i
+ t = scale
+ y = x/.7853
+ s = t + length(y) - scale(y)
+ if(s<t) s=t
+ scale = s
+ p = a(1)
+
+ scale = 0
+ if(x>=0) n = (x/(2*p)+1)/2
+ if(x<0) n = (x/(2*p)-1)/2
+ x = x - 4*n*p
+ if(n%2!=0) x = -x
+
+ scale = t + length(1.2*t) - scale(1.2*t)
+ y = -x*x
+ a = x
+ b = 1
+ s = x
+ for(i=3; 1==1; i=i+2){
+ a = a*y
+ b = b*i*(i-1)
+ c = a/b
+ if(c==0){scale=t; return(s/1)}
+ s = s+c
+ }
+}
+
+define c(x){
+ auto t
+ t = scale
+ scale = scale+1
+ x = s(x+2*a(1))
+ scale = t
+ return(x/1)
+}
+
+define a(x){
+ auto a, b, c, d, e, f, g, s, t
+ if(x==0) return(0)
+ if(x==1) {
+ if(scale<52) {
+ return(.7853981633974483096156608458198757210492923498437764/1)
+ }
+ }
+ t = scale
+ f=1
+ while(x > .5){
+ scale = scale + 1
+ x= -(1-sqrt(1.+x*x))/x
+ f=f*2
+ }
+ while(x < -.5){
+ scale = scale + 1
+ x = -(1-sqrt(1.+x*x))/x
+ f=f*2
+ }
+ s = -x*x
+ b = f
+ c = f
+ d = 1
+ e = 1
+ for(a=3;1==1;a=a+2){
+ b=b*s
+ c=c*a+d*b
+ d=d*a
+ g=c/d
+ if(g==e){
+ scale = t
+ return(x*c/d)
+ }
+ e=g
+ }
+}
+
+define j(n,x){
+ auto a,b,c,d,e,g,i,s,k,t
+
+ t = scale
+ k = 1.36*x + 1.16*t - n
+ k = length(k) - scale(k)
+ if(k>0) scale = scale + k
+
+ s= -x*x/4
+ if(n<0){
+ n= -n
+ x= -x
+ }
+ a=1
+ c=1
+ for(i=1;i<=n;i++){
+ a=a*x
+ c = c*2*i
+ }
+ b=a
+ d=1
+ e=1
+ for(i=1;1;i++){
+ a=a*s
+ b=b*i*(n+i) + a
+ c=c*i*(n+i)
+ g=b/c
+ if(g==e){
+ scale = t
+ return(g/1)
+ }
+ e=g
+ }
+}
di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+[ 0ln-sn 0lx-sx]sK
+[lalx*salc 2*li*sclid1+sis.liln!<L]sL
+[ltklg 1/Lns.Lxs.Las.Lbs.Lcs.Lds.Les.Lgs.Lis.Lss.Lks.Lts. 3Q]sN
+[lals*salbli*lnli+*la+sblcli*lnli+*sclblc/sglgle=N lgselid1+sis. 1 0!=M]sM
+[0St0Sk0Ss0Si0Sg0Se0Sd0Sc0Sb0SaSxSnKst 1.36lx* 1.16lt*+ln-sklkZlkX-sklk 0<J 0lx-lx* 4/ssln 0>K 1sa 1sc 1dsis.liln!<L lasb 1sd 1se 1dsis. 1 0!=M Lns.Lxs.Las.Lbs.Lcs.Lds.Les.Lgs.Lis.Lss.Lks.Lts.0 1Q]s
+
+
+
+q \ No newline at end of file
diff --git a/regress/usr.bin/bc/t2.in b/regress/usr.bin/bc/t2.in
new file mode 100644
index 00000000000..01b746edcb0
--- /dev/null
+++ b/regress/usr.bin/bc/t2.in
@@ -0,0 +1,5 @@
+while (1) {
+ while (0) break;
+ if (a == 1) break;
+ if (a = 2) if (a = 3) break;
+}
diff --git a/regress/usr.bin/bc/t2.out b/regress/usr.bin/bc/t2.out
new file mode 100644
index 00000000000..70a8f4ebdbc
--- /dev/null
+++ b/regress/usr.bin/bc/t2.out
@@ -0,0 +1,7 @@
+[ 1Q 0 0!=1]s1
+[ 2Q]s2
+[ 3Q]s4
+[ 3dsa 0!=4 ]s3
+[ 0 0!=1 la 1=2 2dsa 0!=3 1 0!=0]s0
+ 1 0!=0
+q \ No newline at end of file
diff --git a/regress/usr.bin/bc/t3.in b/regress/usr.bin/bc/t3.in
new file mode 100644
index 00000000000..851f80f6630
--- /dev/null
+++ b/regress/usr.bin/bc/t3.in
@@ -0,0 +1,4 @@
+for (i = 0; i < 10; i++) {
+ a[i] = 3;
+ if (x % 3 == 0) break;
+}
diff --git a/regress/usr.bin/bc/t3.out b/regress/usr.bin/bc/t3.out
new file mode 100644
index 00000000000..920549105e6
--- /dev/null
+++ b/regress/usr.bin/bc/t3.out
@@ -0,0 +1,4 @@
+[ 2Q]s1
+[ 3li:¡lx 3% 0=1 lid1+sis.li 10>0]s0
+ 0dsis.li 10>0
+q \ No newline at end of file
diff --git a/regress/usr.bin/bc/t4.in b/regress/usr.bin/bc/t4.in
new file mode 100644
index 00000000000..d4b13575c5d
--- /dev/null
+++ b/regress/usr.bin/bc/t4.in
@@ -0,0 +1,6 @@
+while (0) while(1) while(2) while(3) while(4) while(5) while(6) while(7) {
+ while (8) while (9) while (10) while (11) while(12) while(13) {
+ while(14) while(15) {
+ }
+ }
+}
diff --git a/regress/usr.bin/bc/t4.out b/regress/usr.bin/bc/t4.out
new file mode 100644
index 00000000000..cd954cc3665
--- /dev/null
+++ b/regress/usr.bin/bc/t4.out
@@ -0,0 +1,18 @@
+[ 15 0!=?]s?
+[ 15 0!=? 14 0!=>]s>
+[ 14 0!=> 13 0!==]s=
+[ 13 0!== 12 0!=<]s<
+[ 12 0!=< 11 0!=;]s;
+[ 11 0!=; 10 0!=:]s:
+[ 10 0!=: 9 0!=9]s9
+[ 9 0!=9 8 0!=8]s8
+[ 8 0!=8 7 0!=7]s7
+[ 7 0!=7 6 0!=6]s6
+[ 6 0!=6 5 0!=5]s5
+[ 5 0!=5 4 0!=4]s4
+[ 4 0!=4 3 0!=3]s3
+[ 3 0!=3 2 0!=2]s2
+[ 2 0!=2 1 0!=1]s1
+[ 1 0!=1 0 0!=0]s0
+ 0 0!=0
+q \ No newline at end of file
diff --git a/regress/usr.bin/bc/t5.in b/regress/usr.bin/bc/t5.in
new file mode 100644
index 00000000000..c02b1b6c5e7
--- /dev/null
+++ b/regress/usr.bin/bc/t5.in
@@ -0,0 +1,7 @@
+define f(a, b, c[]) {
+ auto d,e,f;
+ a=1;
+ return (8);
+}
+
+f(1,2,g[])
diff --git a/regress/usr.bin/bc/t5.out b/regress/usr.bin/bc/t5.out
new file mode 100644
index 00000000000..898e85f50b6
--- /dev/null
+++ b/regress/usr.bin/bc/t5.out
@@ -0,0 +1,6 @@
+[0Sf0Se0SdS£SbSa 1sa 8Las.Lbs.L£s.Lds.Les.Lfs. 1QLas.Lbs.L£s.Lds.Les.Lfs.0 1Q]s
+
+
+
+ 1 2l§lxps.
+q \ No newline at end of file
diff --git a/regress/usr.bin/bc/t6.in b/regress/usr.bin/bc/t6.in
new file mode 100644
index 00000000000..9a196752062
--- /dev/null
+++ b/regress/usr.bin/bc/t6.in
@@ -0,0 +1,3 @@
+if (1)
+for (i=1; i <= 10; i++)
+while (1>0)
diff --git a/regress/usr.bin/bc/t6.out b/regress/usr.bin/bc/t6.out
new file mode 100644
index 00000000000..a47ddf7cf6f
--- /dev/null
+++ b/regress/usr.bin/bc/t6.out
@@ -0,0 +1,7 @@
+[]s0
+ 1 0!=0
+[lid1+sis.li 10!<0]s0
+ 1dsis.li 10!<0
+[ 1 0<0]s0
+ 1 0<0
+q \ No newline at end of file