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: add real-life test cases ...



details:   https://anonhg.NetBSD.org/src/rev/38a486726faf
branches:  trunk
changeset: 376288:38a486726faf
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Jun 09 09:45:55 2023 +0000

description:
tests/indent: add real-life test cases from make(1) and lint(1)

diffstat:

 tests/usr.bin/indent/fmt_decl.c  |  49 +++++++++++++++++++++++++++++++++++++++-
 tests/usr.bin/indent/fmt_expr.c  |  13 +++++++++-
 tests/usr.bin/indent/psym_stmt.c |  17 +++++++++++++-
 3 files changed, 76 insertions(+), 3 deletions(-)

diffs (119 lines):

diff -r 1f574f276494 -r 38a486726faf tests/usr.bin/indent/fmt_decl.c
--- a/tests/usr.bin/indent/fmt_decl.c   Fri Jun 09 08:16:06 2023 +0000
+++ b/tests/usr.bin/indent/fmt_decl.c   Fri Jun 09 09:45:55 2023 +0000
@@ -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
diff -r 1f574f276494 -r 38a486726faf tests/usr.bin/indent/fmt_expr.c
--- a/tests/usr.bin/indent/fmt_expr.c   Fri Jun 09 08:16:06 2023 +0000
+++ b/tests/usr.bin/indent/fmt_expr.c   Fri Jun 09 09:45:55 2023 +0000
@@ -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
diff -r 1f574f276494 -r 38a486726faf tests/usr.bin/indent/psym_stmt.c
--- a/tests/usr.bin/indent/psym_stmt.c  Fri Jun 09 08:16:06 2023 +0000
+++ b/tests/usr.bin/indent/psym_stmt.c  Fri Jun 09 09:45:55 2023 +0000
@@ -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



Home | Main Index | Thread Index | Old Index