diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2024-03-30 07:41:46 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2024-03-30 07:41:46 +0000 |
commit | d75ffb62d682420b80696a36a3ef66b720266e66 (patch) | |
tree | a38d8c2632f7480b6bd3f1c0a4bc56d6a9ab7b4e /regress | |
parent | cb9a1aefad92d62b67d212884b980590840cef7f (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.bt | 29 | ||||
-rw-r--r-- | regress/usr.sbin/btrace/if.ok | 4 |
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 |