summaryrefslogtreecommitdiff
path: root/tests/bc
diff options
context:
space:
mode:
Diffstat (limited to 'tests/bc')
-rw-r--r--tests/bc/scripts/all.txt2
-rw-r--r--tests/bc/scripts/ifs.bc49
-rw-r--r--tests/bc/scripts/ifs.txt18
-rw-r--r--tests/bc/scripts/ifs2.bc33
-rw-r--r--tests/bc/scripts/ifs2.txt34
-rw-r--r--tests/bc/stdin2.txt3
-rw-r--r--tests/bc/stdin2_results.txt21
7 files changed, 160 insertions, 0 deletions
diff --git a/tests/bc/scripts/all.txt b/tests/bc/scripts/all.txt
index 4ebfe5643c3d..0a8d2fe17c6c 100644
--- a/tests/bc/scripts/all.txt
+++ b/tests/bc/scripts/all.txt
@@ -14,3 +14,5 @@ rand.bc
references.bc
screen.bc
strings2.bc
+ifs.bc
+ifs2.bc
diff --git a/tests/bc/scripts/ifs.bc b/tests/bc/scripts/ifs.bc
new file mode 100644
index 000000000000..9d6ab2dbb0ef
--- /dev/null
+++ b/tests/bc/scripts/ifs.bc
@@ -0,0 +1,49 @@
+#! /usr/bin/bc -q
+
+a = 1
+b = 2
+c = 3
+
+if (a == 1) if (b == 2) if (c == 3) print "Yay!\n"
+
+define void g(x) {
+ print "g: x: ", x, "\n"
+}
+
+if (a == 1) {
+ if (b == 2) {
+ if (c == 3) {
+ g(5)
+ }
+ }
+}
+
+define void h(x) {
+ print "h: x: ", x, "\n"
+}
+
+if (z == 0)
+ for (i = 0; i < 2; ++i)
+ if (a == 1)
+ for (j = 0; j < 2; ++j)
+ if (b == 2)
+ for (k = 0; k < 2; ++k)
+ if (c == 3) h(k)
+
+define void i(x) {
+ print "i: x: ", x, "\n"
+}
+
+if (z == 0) {
+ for (i = 0; i < 2; ++i) {
+ if (a == 1) {
+ for (j = 0; j < 2; ++j) {
+ if (b == 2) {
+ for (k = 0; k < 2; ++k) {
+ if (c == 3) i(k)
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/tests/bc/scripts/ifs.txt b/tests/bc/scripts/ifs.txt
new file mode 100644
index 000000000000..56e07330f1f2
--- /dev/null
+++ b/tests/bc/scripts/ifs.txt
@@ -0,0 +1,18 @@
+Yay!
+g: x: 5
+h: x: 0
+h: x: 1
+h: x: 0
+h: x: 1
+h: x: 0
+h: x: 1
+h: x: 0
+h: x: 1
+i: x: 0
+i: x: 1
+i: x: 0
+i: x: 1
+i: x: 0
+i: x: 1
+i: x: 0
+i: x: 1
diff --git a/tests/bc/scripts/ifs2.bc b/tests/bc/scripts/ifs2.bc
new file mode 100644
index 000000000000..052ef06ee4e3
--- /dev/null
+++ b/tests/bc/scripts/ifs2.bc
@@ -0,0 +1,33 @@
+#! /usr/bin/bc -q
+
+a = 1
+b = 2
+c = 3
+
+if (a == 1) if (b == 2) if (c == 3) print "Yay!\n"
+
+define void g(x) {
+ print "g: x: ", x, "\n"
+}
+
+if (a == 1) {
+ if (b == 2) {
+ if (c == 3) {
+ g(5)
+ }
+ }
+}
+
+define void h(x) {
+ print "h: x: ", x, "\n"
+}
+
+if (z == 0)
+ for (i = 0; i < 2; ++i)
+ for (l = 0; l < 2; ++l)
+ if (a == 1)
+ for (j = 0; j < 2; ++j)
+ for (m = 0; m < 2; ++m)
+ if (b == 2)
+ for (k = 0; k < 2; ++k)
+ if (c == 3) h(k)
diff --git a/tests/bc/scripts/ifs2.txt b/tests/bc/scripts/ifs2.txt
new file mode 100644
index 000000000000..b226e98ad44b
--- /dev/null
+++ b/tests/bc/scripts/ifs2.txt
@@ -0,0 +1,34 @@
+Yay!
+g: x: 5
+h: x: 0
+h: x: 1
+h: x: 0
+h: x: 1
+h: x: 0
+h: x: 1
+h: x: 0
+h: x: 1
+h: x: 0
+h: x: 1
+h: x: 0
+h: x: 1
+h: x: 0
+h: x: 1
+h: x: 0
+h: x: 1
+h: x: 0
+h: x: 1
+h: x: 0
+h: x: 1
+h: x: 0
+h: x: 1
+h: x: 0
+h: x: 1
+h: x: 0
+h: x: 1
+h: x: 0
+h: x: 1
+h: x: 0
+h: x: 1
+h: x: 0
+h: x: 1
diff --git a/tests/bc/stdin2.txt b/tests/bc/stdin2.txt
index f260cfa7dbcf..a7f1981c6658 100644
--- a/tests/bc/stdin2.txt
+++ b/tests/bc/stdin2.txt
@@ -1 +1,4 @@
for (i = 0; i < 3; ++i) if (2 < 3) 1
+if (3 < 4) for (i = 0; i < 3; ++i) if (4 < 5) 2
+for (j = 0; j < 3; ++j) if (5 < 6) for (i = 0; i < 3; ++i) if (4 < 5) 3
+if (6 < 7) for (j = 0; j < 3; ++j) if (5 < 6) for (i = 0; i < 3; ++i) if (4 < 5) 4
diff --git a/tests/bc/stdin2_results.txt b/tests/bc/stdin2_results.txt
index e8183f05f5db..43e2b02f53f2 100644
--- a/tests/bc/stdin2_results.txt
+++ b/tests/bc/stdin2_results.txt
@@ -1,3 +1,24 @@
1
1
1
+2
+2
+2
+3
+3
+3
+3
+3
+3
+3
+3
+3
+4
+4
+4
+4
+4
+4
+4
+4
+4