Module Name:    src
Committed By:   rillig
Date:           Mon Oct 18 22:46:34 UTC 2021

Modified Files:
        src/distrib/sets/lists/tests: mi
        src/tests/usr.bin/indent: Makefile
Added Files:
        src/tests/usr.bin/indent: ps_ind_level.c
Removed Files:
        src/tests/usr.bin/indent: ps_ind_level.0 ps_ind_level.0.pro
            ps_ind_level.0.stdout

Log Message:
tests/indent: condense test for indentation level, add missing files


To generate a diff of this commit:
cvs rdiff -u -r1.1145 -r1.1146 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.20 -r1.21 src/tests/usr.bin/indent/Makefile
cvs rdiff -u -r1.2 -r0 src/tests/usr.bin/indent/ps_ind_level.0
cvs rdiff -u -r1.1 -r0 src/tests/usr.bin/indent/ps_ind_level.0.pro
cvs rdiff -u -r1.3 -r0 src/tests/usr.bin/indent/ps_ind_level.0.stdout
cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/indent/ps_ind_level.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.1145 src/distrib/sets/lists/tests/mi:1.1146
--- src/distrib/sets/lists/tests/mi:1.1145	Mon Oct 18 22:30:34 2021
+++ src/distrib/sets/lists/tests/mi	Mon Oct 18 22:46:33 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1145 2021/10/18 22:30:34 rillig Exp $
+# $NetBSD: mi,v 1.1146 2021/10/18 22:46:33 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -5023,9 +5023,10 @@
 ./usr/tests/usr.bin/indent/pcs.0					tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/pcs.0.pro					tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/pcs.0.stdout					tests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/indent/ps_ind_level.0				tests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/indent/ps_ind_level.0.pro				tests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/indent/ps_ind_level.0.stdout			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/ps_ind_level.0				tests-obsolete		obsolete,atf
+./usr/tests/usr.bin/indent/ps_ind_level.0.pro				tests-obsolete		obsolete,atf
+./usr/tests/usr.bin/indent/ps_ind_level.0.stdout			tests-obsolete		obsolete,atf
+./usr/tests/usr.bin/indent/ps_ind_level.c				tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/struct.0					tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/struct.0.stdout				tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/surplusbad.0					tests-usr.bin-tests	compattestfile,atf
@@ -5150,8 +5151,44 @@
 ./usr/tests/usr.bin/indent/token-while_expr.0				tests-obsolete		obsolete,atf
 ./usr/tests/usr.bin/indent/token-while_expr.0.pro			tests-obsolete		obsolete,atf
 ./usr/tests/usr.bin/indent/token-while_expr.0.stdout			tests-obsolete		obsolete,atf
+./usr/tests/usr.bin/indent/token_binary_op.c				tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/token_case_label.c				tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/token_colon.c				tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/token_comma.c				tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/token_comment.c				tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/token_decl.c					tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/token_do_stmt.c				tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/token_end_of_file.c				tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/token_for_exprs.c				tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/token_form_feed.c				tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/token_funcname.c				tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/token_ident.c				tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/token_if_expr.c				tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/token_if_expr_stmt.c				tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/token_if_expr_stmt_else.c			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/token_keyword_do.c				tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/token_keyword_do_else.c			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/token_keyword_else.c				tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/token_keyword_for_if_while.c			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/token_keyword_struct_union_enum.c		tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/token_lbrace.c				tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/token_lparen.c				tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/token_newline.c				tests-usr.bin-tests	compattestfile,atf
+./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_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
+./usr/tests/usr.bin/indent/token_stmt.c					tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/token_stmt_list.c				tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/token_storage_class.c			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/token_string_prefix.c			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/token_switch_expr.c				tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/token_type_def.c				tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/token_unary_op.c				tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/indent/token_while_expr.c				tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/types_from_file.0				tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/types_from_file.0.list			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/indent/types_from_file.0.pro			tests-usr.bin-tests	compattestfile,atf

Index: src/tests/usr.bin/indent/Makefile
diff -u src/tests/usr.bin/indent/Makefile:1.20 src/tests/usr.bin/indent/Makefile:1.21
--- src/tests/usr.bin/indent/Makefile:1.20	Mon Oct 18 22:30:34 2021
+++ src/tests/usr.bin/indent/Makefile	Mon Oct 18 22:46:33 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.20 2021/10/18 22:30:34 rillig Exp $
+#	$NetBSD: Makefile,v 1.21 2021/10/18 22:46:33 rillig Exp $
 
 .include <bsd.own.mk>
 
@@ -137,9 +137,7 @@ FILES+=		parens.0.pro
 FILES+=		pcs.0
 FILES+=		pcs.0.stdout
 FILES+=		pcs.0.pro
-FILES+=		ps_ind_level.0
-FILES+=		ps_ind_level.0.pro
-FILES+=		ps_ind_level.0.stdout
+FILES+=		ps_ind_level.c
 FILES+=		struct.0
 FILES+=		struct.0.stdout
 FILES+=		surplusbad.0

Added files:

Index: src/tests/usr.bin/indent/ps_ind_level.c
diff -u /dev/null src/tests/usr.bin/indent/ps_ind_level.c:1.1
--- /dev/null	Mon Oct 18 22:46:34 2021
+++ src/tests/usr.bin/indent/ps_ind_level.c	Mon Oct 18 22:46:33 2021
@@ -0,0 +1,61 @@
+/* $NetBSD: ps_ind_level.c,v 1.1 2021/10/18 22:46:33 rillig Exp $ */
+/* $FreeBSD$ */
+
+/*
+ * The indentation of the very first line of a file determines the
+ * indentation of the remaining code. Even if later code has a smaller
+ * indentation, it is nevertheless indented to the level given by the first
+ * line of code.
+ *
+ * In this particular test, the indentation is set to 5 and the tabulator
+ * width is set to 8, to demonstrate an off-by-one error in
+ * main_prepare_parsing that has been fixed in indent.c 1.107 from 2021-10-05.
+ *
+ * The declaration in the first line is indented by 3 tabs, amounting to 24
+ * spaces. The initial indentation of the code is intended to be rounded down,
+ * to 4 levels of indentation, amounting to 20 spaces.
+ */
+#indent input
+			int declaration_in_column_25;
+
+void function_in_column_1(void){}
+#indent end
+
+/* 5 spaces indentation, 8 spaces per tabulator */
+#indent run -i5 -ts8
+		    int		    declaration_in_column_25;
+
+		    void	    function_in_column_1(void){
+		    }
+#indent end
+/*
+ * In the above function declaration, the space between '){' is missing. This
+ * is because the tokenizer only recognizes function definitions if they start
+ * at indentation level 0, but this declaration starts at indentation level 4,
+ * due to the indentation in line 1. It's an edge case and probably not worth
+ * fixing.
+ *
+ * See 'in_parameter_declaration = true'.
+ */
+
+
+/*
+ * Labels are always indented 2 levels left of the code. The first line starts
+ * at indentation level 3, the code in the function is therefore at level 4,
+ * and the label is at level 2, sticking out of the code.
+ */
+#indent input
+			int indent_by_24;
+
+void function(void) {
+label:;
+}
+#indent end
+
+#indent run -i8 -ts8 -di0
+			int indent_by_24;
+
+			void function(void){
+		label:		;
+			}
+#indent end

Reply via email to