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 indent: test various forms of comments



details:   https://anonhg.NetBSD.org/src/rev/a264c3e515c0
branches:  trunk
changeset: 1023971:a264c3e515c0
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Oct 05 18:09:13 2021 +0000

description:
indent: test various forms of comments

diffstat:

 tests/usr.bin/indent/token-comment.0        |  90 ++++++++++++++++++++++++++++-
 tests/usr.bin/indent/token-comment.0.pro    |  16 +++-
 tests/usr.bin/indent/token-comment.0.stdout |  86 ++++++++++++++++++++++++++-
 3 files changed, 181 insertions(+), 11 deletions(-)

diffs (235 lines):

diff -r 0a49b92b2786 -r a264c3e515c0 tests/usr.bin/indent/token-comment.0
--- a/tests/usr.bin/indent/token-comment.0      Tue Oct 05 18:00:28 2021 +0000
+++ b/tests/usr.bin/indent/token-comment.0      Tue Oct 05 18:09:13 2021 +0000
@@ -1,16 +1,100 @@
-/* $NetBSD: token-comment.0,v 1.2 2021/03/14 00:50:39 rillig Exp $ */
+/* $NetBSD: token-comment.0,v 1.3 2021/10/05 18:09:13 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
  * Tests for formatting comments.  C99 defines block comments and end-of-line
  * comments.  Indent further distinguishes box comments that are a special
  * kind of block comments.
+ *
+ * See opt-fc1, opt-nfc1.
  */
 
-/* TODO: Add some code to be formatted. */
-
 /* 456789 123456789 123456789 123456789 123456789 123456789 123456789 12345 */
 /* 456789 123456789 123456789 123456789 123456789 123456789 123456789 123456 */
 /* 456789 123456789 123456789 123456789 123456789 123456789 123456789 1234567 */
 /* 456789 123456789 123456789 123456789 123456789 123456789 123456789 12345678 */
 /* 456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 */
+
+/* This is a traditional C block comment. */
+
+// This is a C99 line comment.
+
+/*
+ * This is a box comment since its first line (above this line) is empty.
+ *
+ *
+ *
+ * Its text gets wrapped.
+ * Empty lines serve as paragraphs.
+ */
+
+/**
+ * This is a box comment
+ * that is not re-wrapped.
+ */
+
+/*-
+ * This is a box comment
+ * that is not re-wrapped.
+ * It is often used for copyright declarations.
+ */
+
+void
+function(void)
+{
+       /* This is a traditional C block comment. */
+
+       /*
+        * This is a box comment.
+        *
+        * It starts in column 9, not 1,
+        * therefore it gets re-wrapped.
+        */
+
+       /**
+        * This is a box comment
+        * that is not re-wrapped, even though it starts in column 9, not 1.
+        */
+
+       /*-
+        * This is a box comment
+        * that is not re-wrapped.
+        * It is often used for copyright declarations.
+        */
+
+       int decl;       /* declaration comment */
+
+       int decl;       /* short
+                        * multi-line
+                        * declaration
+                        * comment */
+
+       int decl;       /* long single-line declaration comment that is longer than the allowed line width */
+
+       int decl;       /* long multi-line declaration comment
+ * that is longer than
+ * the allowed line width */
+
+       int decl;       // C99 declaration comment
+
+       code();                 /* code comment */
+
+       code();                 /* short
+                                * multi-line
+                                * code
+                                * comment */
+
+       code();                 /* long single-line code comment that is longer than the allowed line width */
+
+       code();                 /* long multi-line code comment
+ * that is longer than
+ * the allowed line width */
+
+       code();                 // C99 code comment
+}
+
+/*INDENT OFF*/
+/* No formatting takes place here. */
+int format( void ) {{{
+/*INDENT ON*/
+}}}
diff -r 0a49b92b2786 -r a264c3e515c0 tests/usr.bin/indent/token-comment.0.pro
--- a/tests/usr.bin/indent/token-comment.0.pro  Tue Oct 05 18:00:28 2021 +0000
+++ b/tests/usr.bin/indent/token-comment.0.pro  Tue Oct 05 18:09:13 2021 +0000
@@ -1,8 +1,14 @@
-/* $NetBSD: token-comment.0.pro,v 1.1 2021/03/12 00:13:06 rillig Exp $ */
+/* $NetBSD: token-comment.0.pro,v 1.2 2021/10/05 18:09:13 rillig Exp $ */
 /* $FreeBSD$ */
 
-/*
- * TODO: Explain the command line options of the test.
- */
+-ldi0                  /* do not indent local variable declarations */
 
-/* TODO: Add some command line options */
+/* For variations on this theme, try some of these options: */
+/* -c20 */
+/* -cd20 */
+/* -cdb */
+/* -d */
+/* -fc1 */
+/* -fcb */
+/* -lc60 */
+/* -sc */
diff -r 0a49b92b2786 -r a264c3e515c0 tests/usr.bin/indent/token-comment.0.stdout
--- a/tests/usr.bin/indent/token-comment.0.stdout       Tue Oct 05 18:00:28 2021 +0000
+++ b/tests/usr.bin/indent/token-comment.0.stdout       Tue Oct 05 18:09:13 2021 +0000
@@ -1,14 +1,14 @@
-/* $NetBSD: token-comment.0.stdout,v 1.3 2021/03/14 01:34:13 rillig Exp $ */
+/* $NetBSD: token-comment.0.stdout,v 1.4 2021/10/05 18:09:13 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
  * Tests for formatting comments.  C99 defines block comments and end-of-line
  * comments.  Indent further distinguishes box comments that are a special
  * kind of block comments.
+ *
+ * See opt-fc1, opt-nfc1.
  */
 
-/* TODO: Add some code to be formatted. */
-
 /* 456789 123456789 123456789 123456789 123456789 123456789 123456789 12345 */
 /* 456789 123456789 123456789 123456789 123456789 123456789 123456789 123456 */
 /* 456789 123456789 123456789 123456789 123456789 123456789 123456789 1234567 */
@@ -19,3 +19,83 @@
  * 456789 123456789 123456789 123456789 123456789 123456789 123456789
  * 123456789
  */
+
+/* This is a traditional C block comment. */
+
+// This is a C99 line comment.
+
+/*
+ * This is a box comment since its first line (above this line) is empty.
+ *
+ *
+ *
+ * Its text gets wrapped. Empty lines serve as paragraphs.
+ */
+
+/**
+ * This is a box comment
+ * that is not re-wrapped.
+ */
+
+/*-
+ * This is a box comment
+ * that is not re-wrapped.
+ * It is often used for copyright declarations.
+ */
+
+void
+function(void)
+{
+       /* This is a traditional C block comment. */
+
+       /*
+        * This is a box comment.
+        *
+        * It starts in column 9, not 1, therefore it gets re-wrapped.
+        */
+
+       /**
+        * This is a box comment
+        * that is not re-wrapped, even though it starts in column 9, not 1.
+        */
+
+       /*-
+        * This is a box comment
+        * that is not re-wrapped.
+        * It is often used for copyright declarations.
+        */
+
+       int decl;               /* declaration comment */
+
+       int decl;               /* short multi-line declaration comment */
+
+       int decl;               /* long single-line declaration comment that
+                                * is longer than the allowed line width */
+
+       int decl;               /* long multi-line declaration comment that is
+                                * longer than the allowed line width */
+
+       int decl;               // C99 declaration comment
+
+       code();                 /* code comment */
+
+       code();                 /* short multi-line code comment */
+
+       code();                 /* long single-line code comment that is
+                                * longer than the allowed line width */
+
+       code();                 /* long multi-line code comment that is longer
+                                * than the allowed line width */
+
+       code();                 // C99 code comment
+}
+/* $ FIXME: Missing empty line. */
+/*INDENT OFF*/
+/* No formatting takes place here. */
+int format( void ) {{{
+/* $ XXX: Why is the INDENT ON comment indented? */
+/* $ XXX: Why does the INDENT ON comment get spaces, but not the OFF comment? */
+                       /* INDENT ON */
+}
+}
+}



Home | Main Index | Thread Index | Old Index