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 off-by-one er...
details: https://anonhg.NetBSD.org/src/rev/5d39fa76399f
branches: trunk
changeset: 988249:5d39fa76399f
user: rillig <rillig%NetBSD.org@localhost>
date: Tue Oct 05 17:09:45 2021 +0000
description:
tests/indent: demonstrate off-by-one error in edge case
diffstat:
distrib/sets/lists/tests/mi | 5 ++++-
tests/usr.bin/indent/Makefile | 5 ++++-
tests/usr.bin/indent/ps_ind_level.0 | 17 +++++++++++++++++
tests/usr.bin/indent/ps_ind_level.0.pro | 5 +++++
tests/usr.bin/indent/ps_ind_level.0.stdout | 9 +++++++++
5 files changed, 39 insertions(+), 2 deletions(-)
diffs (81 lines):
diff -r 9165a71b0669 -r 5d39fa76399f distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Tue Oct 05 16:36:58 2021 +0000
+++ b/distrib/sets/lists/tests/mi Tue Oct 05 17:09:45 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1131 2021/09/30 02:00:19 yamaguchi Exp $
+# $NetBSD: mi,v 1.1132 2021/10/05 17:09:45 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -4991,6 +4991,9 @@
./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/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
diff -r 9165a71b0669 -r 5d39fa76399f tests/usr.bin/indent/Makefile
--- a/tests/usr.bin/indent/Makefile Tue Oct 05 16:36:58 2021 +0000
+++ b/tests/usr.bin/indent/Makefile Tue Oct 05 17:09:45 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.11 2021/09/25 13:04:55 rillig Exp $
+# $NetBSD: Makefile,v 1.12 2021/10/05 17:09:45 rillig Exp $
.include <bsd.own.mk>
@@ -267,6 +267,9 @@
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+= cs.0
FILES+= cs.0.stdout
FILES+= cs.0.pro
diff -r 9165a71b0669 -r 5d39fa76399f tests/usr.bin/indent/ps_ind_level.0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/indent/ps_ind_level.0 Tue Oct 05 17:09:45 2021 +0000
@@ -0,0 +1,17 @@
+/* $NetBSD: ps_ind_level.0,v 1.1 2021/10/05 17:09:45 rillig Exp $ */
+/* $FreeBSD$ */
+/* $ */
+/* $ The leading indentation in the first line determines the indentation */
+/* $ of the remaining code. In this particular test, the indentation is set */
+/* $ to 5 and the tabulator is set to 8, to demonstrate an off-by-one error */
+/* $ in main_prepare_parsing that has been fixed in indent.c 1.106 from */
+/* $ 2021-10-05. */
+/* $ */
+/* $ The declaration in the below 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. */
+ int declaration_in_column_25;
+
+/* $ Even if later code has a smaller indentation, it is nevertheless */
+/* $ indented to the level given by the first line of code. */
+void function_in_column_1(void){}
diff -r 9165a71b0669 -r 5d39fa76399f tests/usr.bin/indent/ps_ind_level.0.pro
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/indent/ps_ind_level.0.pro Tue Oct 05 17:09:45 2021 +0000
@@ -0,0 +1,5 @@
+/* $NetBSD: ps_ind_level.0.pro,v 1.1 2021/10/05 17:09:45 rillig Exp $ */
+/* $FreeBSD$ */
+
+-i5 /* 5 spaces indentation */
+-ts8 /* 8 spaces per tabulator */
diff -r 9165a71b0669 -r 5d39fa76399f tests/usr.bin/indent/ps_ind_level.0.stdout
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/indent/ps_ind_level.0.stdout Tue Oct 05 17:09:45 2021 +0000
@@ -0,0 +1,9 @@
+/* $NetBSD: ps_ind_level.0.stdout,v 1.1 2021/10/05 17:09:45 rillig Exp $ */
+/* $FreeBSD$ */
+/* $ */
+/* $ FIXME: indentation should be 20 instead of 25. */
+ int declaration_in_column_25;
+
+/* $ FIXME: The space between '){' is missing. */
+ void function_in_column_1(void){
+ }
Home |
Main Index |
Thread Index |
Old Index