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 more tests for option...



details:   https://anonhg.NetBSD.org/src/rev/57b5231fbc5d
branches:  trunk
changeset: 1024456:57b5231fbc5d
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Oct 24 17:51:19 2021 +0000

description:
tests/indent: add more tests for option '-di'

diffstat:

 tests/usr.bin/indent/opt_di.c |  85 ++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 84 insertions(+), 1 deletions(-)

diffs (98 lines):

diff -r 83b8ea105b2c -r 57b5231fbc5d tests/usr.bin/indent/opt_di.c
--- a/tests/usr.bin/indent/opt_di.c     Sun Oct 24 17:46:06 2021 +0000
+++ b/tests/usr.bin/indent/opt_di.c     Sun Oct 24 17:51:19 2021 +0000
@@ -1,6 +1,11 @@
-/* $NetBSD: opt_di.c,v 1.1 2021/10/22 20:54:36 rillig Exp $ */
+/* $NetBSD: opt_di.c,v 1.2 2021/10/24 17:51:19 rillig Exp $ */
 /* $FreeBSD$ */
 
+/*
+ * Test the option '-di', which specifies the indentation of the variable
+ * declarator.
+ */
+
 #indent input
 int space;
 int    tab;
@@ -16,3 +21,81 @@
 
 struct long_name long_name;
 #indent end
+
+
+/*
+ * The declarator can be a simple variable name. It can also be prefixed by
+ * asterisks, for pointer variables. These asterisks are placed to the left of
+ * the indentation line, so that the variable names are aligned.
+ *
+ * There can be multiple declarators in a single declaration, separated by
+ * commas. Only the first of them is aligned to the indentation given by
+ * '-di', the others are separated with a single space.
+ */
+#indent input
+int var;
+int *ptr, *****ptr;
+#indent end
+
+#indent run -di12
+int        var;
+int       *ptr, *****ptr;
+#indent end
+
+
+/*
+ * Test the various values for indenting.
+ */
+#indent input
+int decl ;
+#indent end
+
+/*
+ * An indentation of 0 columns uses a single space between the declaration
+ * specifiers (in this case 'int') and the declarator.
+ */
+#indent run -di0
+int decl;
+#indent end
+
+/*
+ * An indentation of 7 columns uses spaces for indentation since in the
+ * default configuration, the next tab stop would be at indentation 8.
+ */
+#indent run -di7
+int    decl;
+#indent end
+
+/* The indentation consists of a single tab. */
+#indent run -di8
+int    decl;
+#indent end
+
+/* The indentation consists of a tab and a space. */
+#indent run -di9
+int     decl;
+#indent end
+
+#indent run -di16
+int            decl;
+#indent end
+
+
+/*
+ * Ensure that all whitespace is normalized to be indented by 8 columns,
+ * which in the default configuration amounts to a single tab.
+ */
+
+#indent input
+int space;
+int    tab;
+int            tab16;
+struct long_name long_name;
+#indent end
+
+#indent run -di8
+int    space;
+int    tab;
+int    tab16;
+struct long_name long_name;
+#indent end



Home | Main Index | Thread Index | Old Index