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: migrate token_question to...



details:   https://anonhg.NetBSD.org/src/rev/574cd5ca6fe9
branches:  trunk
changeset: 1026552:574cd5ca6fe9
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Nov 28 16:20:13 2021 +0000

description:
tests/indent: migrate token_question to lsym_question and extend it

diffstat:

 distrib/sets/lists/tests/mi           |   4 +-
 tests/usr.bin/indent/Makefile         |   3 +-
 tests/usr.bin/indent/lsym_question.c  |  59 +++++++++++++++++++++++++++++++++-
 tests/usr.bin/indent/token_question.c |  14 --------
 4 files changed, 60 insertions(+), 20 deletions(-)

diffs (126 lines):

diff -r d468a4f14507 -r 574cd5ca6fe9 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Sun Nov 28 16:05:59 2021 +0000
+++ b/distrib/sets/lists/tests/mi       Sun Nov 28 16:20:13 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1172 2021/11/28 16:05:59 rillig Exp $
+# $NetBSD: mi,v 1.1173 2021/11/28 16:20:13 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -5268,7 +5268,7 @@
 ./usr/tests/usr.bin/indent/token_period.c                              tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/indent/token_postfix_op.c                          tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/indent/token_preprocessing.c                       tests-usr.bin-tests     compattestfile,atf
-./usr/tests/usr.bin/indent/token_question.c                            tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/token_question.c                            tests-obsolete          obsolete,atf
 ./usr/tests/usr.bin/indent/token_rbrace.c                              tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/indent/token_rparen.c                              tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/indent/token_semicolon.c                           tests-usr.bin-tests     compattestfile,atf
diff -r d468a4f14507 -r 574cd5ca6fe9 tests/usr.bin/indent/Makefile
--- a/tests/usr.bin/indent/Makefile     Sun Nov 28 16:05:59 2021 +0000
+++ b/tests/usr.bin/indent/Makefile     Sun Nov 28 16:20:13 2021 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.38 2021/11/28 16:05:59 rillig Exp $
+#      $NetBSD: Makefile,v 1.39 2021/11/28 16:20:13 rillig Exp $
 
 .include <bsd.own.mk>
 
@@ -133,7 +133,6 @@
 FILES+=                token_period.c
 FILES+=                token_postfix_op.c
 FILES+=                token_preprocessing.c
-FILES+=                token_question.c
 FILES+=                token_rbrace.c
 FILES+=                token_rparen.c
 FILES+=                token_semicolon.c
diff -r d468a4f14507 -r 574cd5ca6fe9 tests/usr.bin/indent/lsym_question.c
--- a/tests/usr.bin/indent/lsym_question.c      Sun Nov 28 16:05:59 2021 +0000
+++ b/tests/usr.bin/indent/lsym_question.c      Sun Nov 28 16:20:13 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_question.c,v 1.1 2021/11/18 21:19:19 rillig Exp $ */
+/* $NetBSD: lsym_question.c,v 1.2 2021/11/28 16:20:13 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -7,7 +7,62 @@
  */
 
 #indent input
-// TODO: add input
+const char *result = cond ? "then" : "else";
+
+const char *multi = cond1 ? "cond1" : cond2 ? "cond2" : cond3 ? "cond3" : "";
+#indent end
+
+#indent run-equals-input -di0
+
+
+/*
+ * To make them easier to read, conditional expressions can be split into
+ * multiple lines.
+ */
+#indent input
+const char *separate_lines = cond
+       ? "then"
+       : "else";
+#indent end
+
+#indent run -di0
+const char *separate_lines = cond
+// $ XXX: Continuation lines in expressions should be indented, even in column 1.
+? "then"
+: "else";
+#indent end
+
+
+/*
+ * In functions, conditional expressions are indented as intended.
+ */
+#indent input
+void
+function(void)
+{
+       return cond
+               ? "then"
+               : "else";
+}
 #indent end
 
 #indent run-equals-input
+
+
+/*
+ * In functions, conditional expressions are indented as intended.
+ */
+#indent input
+void
+function(void)
+{
+       const char *branch = cond
+       // $ TODO: Indent these continuation lines as they are part of the
+       // $ TODO: initializer expression, not of the declarator part to the
+       // $ TODO: left of the '='.
+       ? "then"
+       : "else";
+}
+#indent end
+
+#indent run-equals-input -di0
diff -r d468a4f14507 -r 574cd5ca6fe9 tests/usr.bin/indent/token_question.c
--- a/tests/usr.bin/indent/token_question.c     Sun Nov 28 16:05:59 2021 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-/* $NetBSD: token_question.c,v 1.1 2021/10/18 22:30:34 rillig Exp $ */
-/* $FreeBSD$ */
-
-/*
- * Tests for the '?:' operator.
- */
-
-#indent input
-int var = cond ? 1 : 0;
-
-int multi = cond ? 1 : cond ? 2 : cond ? 3 : 4;
-#indent end
-
-#indent run-equals-input -di0



Home | Main Index | Thread Index | Old Index