summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2024-03-30 07:41:46 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2024-03-30 07:41:46 +0000
commitd75ffb62d682420b80696a36a3ef66b720266e66 (patch)
treea38d8c2632f7480b6bd3f1c0a4bc56d6a9ab7b4e /regress
parentcb9a1aefad92d62b67d212884b980590840cef7f (diff)
Implement else branching logic including 'else if'.
Statement lists for if & else conditions are now wrapped in a new 'struct bt_cond'. Handling B_AC_TEST statements moved to stmt_eval() to handle nested conditional statements. From Christian Ludwig christian_ludwig at genua.de
Diffstat (limited to 'regress')
-rw-r--r--regress/usr.sbin/btrace/if.bt29
-rw-r--r--regress/usr.sbin/btrace/if.ok4
2 files changed, 33 insertions, 0 deletions
diff --git a/regress/usr.sbin/btrace/if.bt b/regress/usr.sbin/btrace/if.bt
index 053801cac54..41f30815ba5 100644
--- a/regress/usr.sbin/btrace/if.bt
+++ b/regress/usr.sbin/btrace/if.bt
@@ -9,6 +9,20 @@ BEGIN {
if (1) {
printf("printed!\n");
}
+
+ if (0)
+ printf("simple if\n");
+ else
+ printf("simple else\n");
+
+ if (0) {
+ printf("disabled if\n");
+ } else if (1) {
+ printf("multiple statements in ");
+ printf("else-if branch\n");
+ } else {
+ printf("no else\n");
+ }
}
END {
@@ -18,4 +32,19 @@ END {
printf("(%d) ", @var);
printf("statements\n");
}
+
+ if (0) printf("single-line if\n"); else printf("single-line else\n");
+
+ if (0) {
+ printf("not printed\n");
+ } else {
+ if (0) {
+ printf("nested not printed\n");
+ } else {
+ printf("nested printed\n");
+ exit();
+ printf("nested not printed\n");
+ }
+ printf("also not printed\n");
+ }
}
diff --git a/regress/usr.sbin/btrace/if.ok b/regress/usr.sbin/btrace/if.ok
index c2d5a91bc90..cfac256dac6 100644
--- a/regress/usr.sbin/btrace/if.ok
+++ b/regress/usr.sbin/btrace/if.ok
@@ -1,2 +1,6 @@
printed!
+simple else
+multiple statements in else-if branch
multiple (4) statements
+single-line else
+nested printed