Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/usr.bin/indent tests/indent: test variants of the 'ret...
details: https://anonhg.NetBSD.org/src/rev/00d5098c962d
branches: trunk
changeset: 1026553:00d5098c962d
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Nov 28 16:31:39 2021 +0000
description:
tests/indent: test variants of the 'return' statement
diffstat:
tests/usr.bin/indent/lsym_return.c | 62 ++++++++++++++++++++++++++++++++++++-
1 files changed, 60 insertions(+), 2 deletions(-)
diffs (77 lines):
diff -r 574cd5ca6fe9 -r 00d5098c962d tests/usr.bin/indent/lsym_return.c
--- a/tests/usr.bin/indent/lsym_return.c Sun Nov 28 16:20:13 2021 +0000
+++ b/tests/usr.bin/indent/lsym_return.c Sun Nov 28 16:31:39 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_return.c,v 1.1 2021/11/18 21:19:19 rillig Exp $ */
+/* $NetBSD: lsym_return.c,v 1.2 2021/11/28 16:31:39 rillig Exp $ */
/* $FreeBSD$ */
/*
@@ -6,8 +6,66 @@
* starts a 'return' statement for leaving the execution of a function.
*/
+/*
+ * Return statements having a single-line expression are simple to format.
+ * Since 'return' is not a function name, there is a space between the
+ * 'return' and the '('.
+ */
#indent input
-// TODO: add input
+void
+function(bool cond)
+{
+ if (cond)
+ return;
+}
+
+int
+calculate(int a, int b)
+{
+ return a;
+ return (b);
+ return (((a))) + b;
+ return calculate(b, a);
+}
#indent end
#indent run-equals-input
+
+
+/*
+ * Returning complex expressions may spread the expression over several lines.
+ * The exact formatting depends on the option '-lp'.
+ */
+#indent input
+int
+multi_line(int a)
+{
+ return calculate(3,
+ 4);
+ return calculate(
+ 3,
+ 4);
+ return calculate(
+ 3,
+ 4
+ );
+}
+#indent end
+
+#indent run-equals-input
+
+#indent run -nlp
+int
+multi_line(int a)
+{
+ return calculate(3,
+ 4);
+ return calculate(
+ 3,
+ 4);
+ return calculate(
+ 3,
+ 4
+ );
+}
+#indent end
Home |
Main Index |
Thread Index |
Old Index