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: demonstrate strange align...



details:   https://anonhg.NetBSD.org/src/rev/b4f865ecfff1
branches:  trunk
changeset: 953471:b4f865ecfff1
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Mar 09 20:43:19 2021 +0000

description:
tests/indent: demonstrate strange alignment for global variables

diffstat:

 distrib/sets/lists/tests/mi                    |   5 +-
 tests/usr.bin/indent/Makefile                  |  64 +++++++++++++++++++++++++-
 tests/usr.bin/indent/indent_variables.0        |  22 ++++++++
 tests/usr.bin/indent/indent_variables.0.pro    |   5 ++
 tests/usr.bin/indent/indent_variables.0.stdout |  36 ++++++++++++++
 5 files changed, 130 insertions(+), 2 deletions(-)

diffs (177 lines):

diff -r 46f428c8c89e -r b4f865ecfff1 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Tue Mar 09 19:46:28 2021 +0000
+++ b/distrib/sets/lists/tests/mi       Tue Mar 09 20:43:19 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1029 2021/03/08 22:13:05 rillig Exp $
+# $NetBSD: mi,v 1.1030 2021/03/09 20:43:19 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -4727,6 +4727,9 @@
 ./usr/tests/usr.bin/indent/f_decls.0.stdout            tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/indent/float.0                     tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/indent/float.0.stdout              tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/indent_variables.0          tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/indent_variables.0.pro      tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/indent_variables.0.stdout   tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/indent/label.0                     tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/indent/label.0.pro                 tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/indent/label.0.stdout              tests-usr.bin-tests     compattestfile,atf
diff -r 46f428c8c89e -r b4f865ecfff1 tests/usr.bin/indent/Makefile
--- a/tests/usr.bin/indent/Makefile     Tue Mar 09 19:46:28 2021 +0000
+++ b/tests/usr.bin/indent/Makefile     Tue Mar 09 20:43:19 2021 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.6 2021/03/08 22:13:05 rillig Exp $
+#      $NetBSD: Makefile,v 1.7 2021/03/09 20:43:20 rillig Exp $
 
 .include <bsd.own.mk>
 
@@ -24,6 +24,9 @@
 FILES+=                f_decls.0.stdout
 FILES+=                float.0
 FILES+=                float.0.stdout
+FILES+=                indent_variables.0
+FILES+=                indent_variables.0.pro
+FILES+=                indent_variables.0.stdout
 FILES+=                label.0
 FILES+=                label.0.stdout
 FILES+=                label.0.pro
@@ -269,4 +272,63 @@
 FILES+=                wchar.0
 FILES+=                wchar.0.stdout
 
+add-test: .PHONY
+       @set -eu; \
+       test=${NAME:Q}; \
+       [ "$$test" ] || { \
+               echo "usage: ${MAKE} add-test NAME=<name>"; \
+               exit; \
+       }; \
+       \
+       if [ -f "$$test" ]; then \
+               echo "error: test $$test already exists." 1>&2; \
+               exit 1; \
+       fi; \
+       \
+       echo "=> Adding test $$test"; \
+       printf '%s\n' \
+               '/* $$''NetBSD$$ */' \
+               '/* $$''FreeBSD$$ */' \
+               '' \
+               '/*' \
+               ' * TODO: Explain the purpose of the test.' \
+               '*/' \
+               '' \
+               '// TODO: Add some code that passes.' \
+       > "$$test"; \
+       printf '%s\n' \
+               '/* $$''NetBSD$$ */' \
+               '/* $$''FreeBSD$$ */' \
+               '' \
+               '/*' \
+               ' * TODO: Explain the command line options of the test.' \
+               ' */' \
+               '' \
+               '/* TODO: Add some command line options */' \
+       > "$$test.pro"; \
+       cat < "$$test" > "$$test.stdout"; \
+       cvs add "$$test" "$$test.pro" "$$test.stdout"; \
+       printf '%s\n' \
+               '/^FILES+=/i' \
+               "FILES+=                $$test" \
+               "FILES+=                $$test.pro" \
+               "FILES+=                $$test.stdout" \
+               '.' 'w' 'q' \
+       | ed Makefile; \
+       ${MAKE} sync-mi
+
+# Note: only works for adding tests.
+# To remove a test, the $$mi file must be edited manually.
+sync-mi: .PHONY
+       @set -eu;                                                       \
+       cd "${MAKEFILE:tA:H}/../../..";                                 \
+       mi="distrib/sets/lists/tests/mi";                               \
+       cvs update "$$mi";                                              \
+       fmt="./usr/tests/usr.bin/indent/%s\ttests-usr.bin-tests\tcompattestfile,atf\n"; \
+       cat "$$mi" > "$$mi.tmp";                                        \
+       printf "$$fmt" ${FILES:M${NAME}*} >> "$$mi.tmp";                \
+       distrib/sets/fmt-list "$$mi.tmp";                               \
+       mv "$$mi.tmp" "$$mi";                                           \
+       cvs diff "$$mi" || true
+
 .include <bsd.test.mk>
diff -r 46f428c8c89e -r b4f865ecfff1 tests/usr.bin/indent/indent_variables.0
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/indent/indent_variables.0   Tue Mar 09 20:43:19 2021 +0000
@@ -0,0 +1,22 @@
+/* $NetBSD: indent_variables.0,v 1.1 2021/03/09 20:43:20 rillig Exp $ */
+/* $FreeBSD$ */
+
+/*-
+ * Demonstrate how variable declarations are broken into several lines when
+ * the line length limit is set quite low.
+ */
+
+struct s0 a,b;
+struct s01 a,b;
+struct s012 a,b;
+struct s0123 a,b;
+struct s01234 a,b;
+struct s012345 a,b;
+struct s0123456 a,b;
+struct s01234567 a,b;
+struct s012345678 a,b;
+struct s0123456789 a,b;
+struct s01234567890 a,b;
+struct s012345678901 a,b;
+struct s0123456789012 a,b;
+struct s01234567890123 a,b;
diff -r 46f428c8c89e -r b4f865ecfff1 tests/usr.bin/indent/indent_variables.0.pro
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/indent/indent_variables.0.pro       Tue Mar 09 20:43:19 2021 +0000
@@ -0,0 +1,5 @@
+/* $NetBSD: indent_variables.0.pro,v 1.1 2021/03/09 20:43:20 rillig Exp $ */
+/* $FreeBSD$ */
+
+-l20
+-di0
diff -r 46f428c8c89e -r b4f865ecfff1 tests/usr.bin/indent/indent_variables.0.stdout
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/indent/indent_variables.0.stdout    Tue Mar 09 20:43:19 2021 +0000
@@ -0,0 +1,36 @@
+/* $NetBSD: indent_variables.0.stdout,v 1.1 2021/03/09 20:43:20 rillig Exp $ */
+/* $FreeBSD$ */
+
+/*-
+ * Demonstrate how variable declarations are broken into several lines when
+ * the line length limit is set quite low.
+ */
+
+struct s0 a,
+   b;
+struct s01 a,
+    b;
+struct s012 a,
+     b;
+struct s0123 a,
+      b;
+struct s01234 a,
+       b;
+struct s012345 a,
+        b;
+struct s0123456 a,
+         b;
+struct s01234567 a,
+          b;
+struct s012345678 a,
+           b;
+struct s0123456789 a,
+            b;
+struct s01234567890 a,
+             b;
+struct s012345678901 a,
+              b;
+struct s0123456789012 a,
+               b;
+struct s01234567890123 a,
+                b;



Home | Main Index | Thread Index | Old Index