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 cast, line counting,...



details:   https://anonhg.NetBSD.org/src/rev/0f4cdcbd1ac6
branches:  trunk
changeset: 991106:0f4cdcbd1ac6
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Nov 07 15:44:28 2021 +0000

description:
tests/indent: test cast, line counting, comment in struct

diffstat:

 tests/usr.bin/indent/opt_cs.c                          |  24 ++++++++++++-
 tests/usr.bin/indent/opt_v.c                           |  32 +++++++++++++++++-
 tests/usr.bin/indent/token_keyword_struct_union_enum.c |  12 ++++++-
 3 files changed, 65 insertions(+), 3 deletions(-)

diffs (101 lines):

diff -r e9c5b55db9ec -r 0f4cdcbd1ac6 tests/usr.bin/indent/opt_cs.c
--- a/tests/usr.bin/indent/opt_cs.c     Sun Nov 07 15:18:25 2021 +0000
+++ b/tests/usr.bin/indent/opt_cs.c     Sun Nov 07 15:44:28 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_cs.c,v 1.3 2021/10/16 21:32:10 rillig Exp $ */
+/* $NetBSD: opt_cs.c,v 1.4 2021/11/07 15:44:28 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -26,3 +26,25 @@
 int            i1 = (int)3.0;
 int            i3 = (int)3.0;
 #indent end
+
+
+#indent input
+struct s       s3 = (struct s)   s;
+struct s       *ptr = (struct s *)   s;
+union u                u3 = (union u)   u;
+enum e         e3 = (enum e)   e;
+#indent end
+
+#indent run -cs
+struct s       s3 = (struct s) s;
+struct s       *ptr = (struct s *) s;
+union u                u3 = (union u) u;
+enum e         e3 = (enum e) e;
+#indent end
+
+#indent run -ncs
+struct s       s3 = (struct s)s;
+struct s       *ptr = (struct s *)s;
+union u                u3 = (union u)u;
+enum e         e3 = (enum e)e;
+#indent end
diff -r e9c5b55db9ec -r 0f4cdcbd1ac6 tests/usr.bin/indent/opt_v.c
--- a/tests/usr.bin/indent/opt_v.c      Sun Nov 07 15:18:25 2021 +0000
+++ b/tests/usr.bin/indent/opt_v.c      Sun Nov 07 15:44:28 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_v.c,v 1.3 2021/10/22 19:27:53 rillig Exp $ */
+/* $NetBSD: opt_v.c,v 1.4 2021/11/07 15:44:28 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -90,3 +90,33 @@
  * XXX: It's rather strange that -v writes to stdout, even in filter mode.
  * This output belongs on stderr instead.
  */
+
+
+/*
+ * Test line counting in preprocessor directives.
+ */
+#indent input
+#if 0
+int line = 1;
+int line = 2;
+int line = 3;
+#else
+int line = 5;
+#endif
+#indent end
+
+#indent run -v -di0
+#if 0
+int line = 1;
+int line = 2;
+int line = 3;
+#else
+int line = 5;
+#endif
+There were 3 output lines and 0 comments
+(Lines with comments)/(Lines with code):  0.000
+#indent end
+/*
+ * FIXME: The lines within the conditional compilation directives must be
+ * counted as well. TODO: Move stats out of parser_state.
+ */
diff -r e9c5b55db9ec -r 0f4cdcbd1ac6 tests/usr.bin/indent/token_keyword_struct_union_enum.c
--- a/tests/usr.bin/indent/token_keyword_struct_union_enum.c    Sun Nov 07 15:18:25 2021 +0000
+++ b/tests/usr.bin/indent/token_keyword_struct_union_enum.c    Sun Nov 07 15:44:28 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: token_keyword_struct_union_enum.c,v 1.2 2021/10/22 19:46:41 rillig Exp $ */
+/* $NetBSD: token_keyword_struct_union_enum.c,v 1.3 2021/11/07 15:44:28 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -68,3 +68,13 @@
        struct y        c = (struct y *)&a;
 }
 #indent end
+
+
+/* Comment between 'struct' and the tag name; doesn't occur in practice. */
+#indent input
+struct   /* comment */   tag var;
+#indent end
+
+#indent run -di0
+struct /* comment */ tag var;
+#indent end



Home | Main Index | Thread Index | Old Index