Module Name:    src
Committed By:   rillig
Date:           Sun Nov 28 16:31:39 UTC 2021

Modified Files:
        src/tests/usr.bin/indent: lsym_return.c

Log Message:
tests/indent: test variants of the 'return' statement


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/lsym_return.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/usr.bin/indent/lsym_return.c
diff -u src/tests/usr.bin/indent/lsym_return.c:1.1 src/tests/usr.bin/indent/lsym_return.c:1.2
--- src/tests/usr.bin/indent/lsym_return.c:1.1	Thu Nov 18 21:19:19 2021
+++ src/tests/usr.bin/indent/lsym_return.c	Sun Nov 28 16:31:39 2021
@@ -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

Reply via email to