summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2003-12-09 12:49:02 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2003-12-09 12:49:02 +0000
commitd29dfe98545e37462892fc09086f7e3a26113fd9 (patch)
tree16b0b4ed95c5ec602b56c48faa67577426b4bbb5 /regress
parentca9cca296a75d6ec551ed6d989d5dda291cf8ce5 (diff)
Towers of Hanoi regression test.
BSD license with permission from author Amit Singh <amit_s at acm dot org>.
Diffstat (limited to 'regress')
-rw-r--r--regress/usr.bin/bc/Makefile5
-rw-r--r--regress/usr.bin/bc/t18.in45
-rw-r--r--regress/usr.bin/bc/t18.out22
3 files changed, 70 insertions, 2 deletions
diff --git a/regress/usr.bin/bc/Makefile b/regress/usr.bin/bc/Makefile
index fa6eed9ad38..9a0cb50adb5 100644
--- a/regress/usr.bin/bc/Makefile
+++ b/regress/usr.bin/bc/Makefile
@@ -1,8 +1,8 @@
-# $OpenBSD: Makefile,v 1.8 2003/12/02 09:02:02 otto Exp $
+# $OpenBSD: Makefile,v 1.9 2003/12/09 12:49:01 otto Exp $
BC=bc
-REGRESS_TARGETS=t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17
+REGRESS_TARGETS=t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18
# .in: input file
# .out: desired result
@@ -24,6 +24,7 @@ REGRESS_TARGETS=t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17
# t15: boolean and
# t16: boolean or
# t17: long var names
+# t18: towers of hanoi
all: clean ${REGRESS_TARGET}
diff --git a/regress/usr.bin/bc/t18.in b/regress/usr.bin/bc/t18.in
new file mode 100644
index 00000000000..1f989a228b8
--- /dev/null
+++ b/regress/usr.bin/bc/t18.in
@@ -0,0 +1,45 @@
+/* $OpenBSD: t18.in,v 1.1 2003/12/09 12:49:01 otto Exp $ */
+/*
+ * Copyright (c) 2003 Amit Singh <amit_s@acm.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
+ * The Towers Of Hanoi
+ * bc version
+ * http://hanoi.kernelthread.com
+ */
+
+define moveit(i, j) {
+ print "move "
+ print i
+ print " --> "
+ print j
+ print "\n"
+}
+
+define dohanoi(n, h, d, o) {
+ if (n > 0) {
+ silence = dohanoi(n-1, h, o, d)
+ silence = moveit(h, d)
+ silence = dohanoi(n-1, o, d, h)
+ }
+}
+
+define hanoi(n) {
+ silence = dohanoi(n, 1, 3, 2)
+}
+
+hanoi(5)
+
diff --git a/regress/usr.bin/bc/t18.out b/regress/usr.bin/bc/t18.out
new file mode 100644
index 00000000000..01ce2a70ba6
--- /dev/null
+++ b/regress/usr.bin/bc/t18.out
@@ -0,0 +1,22 @@
+
+
+
+
+
+[SjSi[move ]nlids.n[ --> ]nljds.n[
+]nLis.Ljs.0 1Q]sÿ
+
+
+
+[ln 1-lhloldlÿxsÿlhldlÿxsÿln 1-loldlhlÿxsÿ]s0
+[SoSdShSnln 0<0 Lns.Lhs.Lds.Los.0 1Q]sÿ
+
+
+
+[Snln 1 3 2lÿxsÿLns.0 1Q]sÿ
+
+
+
+ 5lÿxps.
+
+q \ No newline at end of file