Module Name: src
Committed By: rillig
Date: Fri Jun 9 09:45:55 UTC 2023
Modified Files:
src/tests/usr.bin/indent: fmt_decl.c fmt_expr.c psym_stmt.c
Log Message:
tests/indent: add real-life test cases from make(1) and lint(1)
To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/tests/usr.bin/indent/fmt_decl.c
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/fmt_expr.c \
src/tests/usr.bin/indent/psym_stmt.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/fmt_decl.c
diff -u src/tests/usr.bin/indent/fmt_decl.c:1.50 src/tests/usr.bin/indent/fmt_decl.c:1.51
--- src/tests/usr.bin/indent/fmt_decl.c:1.50 Thu Jun 8 21:18:54 2023
+++ src/tests/usr.bin/indent/fmt_decl.c Fri Jun 9 09:45:55 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: fmt_decl.c,v 1.50 2023/06/08 21:18:54 rillig Exp $ */
+/* $NetBSD: fmt_decl.c,v 1.51 2023/06/09 09:45:55 rillig Exp $ */
/*
* Tests for declarations of global variables, external functions, and local
@@ -153,6 +153,7 @@ t2(char *x, int y)
//indent input
const int int_minimum_size =
+// $ FIXME: Missing indentation.
MAXALIGN(offsetof(int, test)) + MAXIMUM_ALIGNOF;
//indent end
@@ -1002,3 +1003,49 @@ struct a {
//indent end
//indent run-equals-input -di0
+
+
+//indent input
+static FILE *ArchFindMember(const char *, const char *,
+ struct ar_hdr *, const char *);
+
+bool
+Job_CheckCommands(GNode *gn, void (*abortProc)(const char *, ...))
+{
+}
+
+static void MAKE_ATTR_PRINTFLIKE(5, 0)
+ParseVErrorInternal(FILE *f, bool useVars, const GNode *gn,
+ ParseErrorLevel level, const char *fmt, va_list ap)
+{
+}
+
+typedef struct {
+ const char *m_name;
+} mod_t;
+//indent end
+
+//indent run -fbs -di0 -psl
+// $ FIXME: Must be detected as a function declaration, not a definition.
+static FILE *
+ArchFindMember(const char *, const char *,
+ struct ar_hdr *, const char *);
+
+bool
+Job_CheckCommands(GNode *gn, void (*abortProc)(const char *, ...))
+{
+}
+
+static void
+MAKE_ATTR_PRINTFLIKE(5, 0)
+ParseVErrorInternal(FILE *f, bool useVars, const GNode *gn,
+ ParseErrorLevel level, const char *fmt, va_list ap)
+{
+}
+
+typedef struct {
+ const char *m_name;
+}
+// $ FIXME: Remove this line break.
+mod_t;
+//indent end
Index: src/tests/usr.bin/indent/fmt_expr.c
diff -u src/tests/usr.bin/indent/fmt_expr.c:1.4 src/tests/usr.bin/indent/fmt_expr.c:1.5
--- src/tests/usr.bin/indent/fmt_expr.c:1.4 Sun Apr 24 09:04:12 2022
+++ src/tests/usr.bin/indent/fmt_expr.c Fri Jun 9 09:45:55 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: fmt_expr.c,v 1.4 2022/04/24 09:04:12 rillig Exp $ */
+/* $NetBSD: fmt_expr.c,v 1.5 2023/06/09 09:45:55 rillig Exp $ */
/*
* Tests for all kinds of expressions that are not directly related to unary
@@ -23,3 +23,14 @@ t(void)
int n = malloc(offsetof(struct s, f) + 1);
}
//indent end
+
+
+//indent input
+{
+ for (ln = gnodes->first; ln != NULL; ln = ln->next)
+// $ FIXME: No space after the cast.
+ *(GNode **) Vector_Push(&vec) = ln->datum;
+}
+//indent end
+
+//indent run-equals-input
Index: src/tests/usr.bin/indent/psym_stmt.c
diff -u src/tests/usr.bin/indent/psym_stmt.c:1.4 src/tests/usr.bin/indent/psym_stmt.c:1.5
--- src/tests/usr.bin/indent/psym_stmt.c:1.4 Sun Apr 24 10:36:37 2022
+++ src/tests/usr.bin/indent/psym_stmt.c Fri Jun 9 09:45:55 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: psym_stmt.c,v 1.4 2022/04/24 10:36:37 rillig Exp $ */
+/* $NetBSD: psym_stmt.c,v 1.5 2023/06/09 09:45:55 rillig Exp $ */
/*
* Tests for the parser symbol psym_stmt, which represents a statement on the
@@ -26,3 +26,18 @@ function(void)
* syntactic macro, especially not when its definition is in a header file.
*/
//indent run-equals-input
+
+
+//indent input
+{
+ TAILQ_FOREACH(a, b, c) {
+ a =
+// $ FIXME: The 'b' must be indented as a continuation.
+// $ The '{' in line 2 sets ps.block_init though, even though it does not
+// $ follow a '='.
+ b;
+ }
+}
+//indent end
+
+//indent run-equals-input -di0 -nlp -ci4