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: test formatting of while ...



details:   https://anonhg.NetBSD.org/src/rev/28b5652f25b9
branches:  trunk
changeset: 1023744:28b5652f25b9
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Sep 25 13:26:07 2021 +0000

description:
tests/indent: test formatting of while and do-while loops

diffstat:

 tests/usr.bin/indent/token-while_expr.0        |   5 +++--
 tests/usr.bin/indent/token-while_expr.0.stdout |  19 +++++++++++++++++--
 2 files changed, 20 insertions(+), 4 deletions(-)

diffs (44 lines):

diff -r 17e9c337ab3a -r 28b5652f25b9 tests/usr.bin/indent/token-while_expr.0
--- a/tests/usr.bin/indent/token-while_expr.0   Sat Sep 25 13:04:55 2021 +0000
+++ b/tests/usr.bin/indent/token-while_expr.0   Sat Sep 25 13:26:07 2021 +0000
@@ -1,8 +1,9 @@
-/* $NetBSD: token-while_expr.0,v 1.1 2021/03/12 00:13:06 rillig Exp $ */
+/* $NetBSD: token-while_expr.0,v 1.2 2021/09/25 13:26:07 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
  * Tests for the keyword 'while', followed by a parenthesized expression.
  */
 
-/* TODO: Add some code to be formatted. */
+int main(int argc,char**argv){int o;while((o=getopt(argc,argv,"x:"))!=-1)
+switch(o){case'x':do{o++;}while(o<5);break;default:usage();}return 0;}
diff -r 17e9c337ab3a -r 28b5652f25b9 tests/usr.bin/indent/token-while_expr.0.stdout
--- a/tests/usr.bin/indent/token-while_expr.0.stdout    Sat Sep 25 13:04:55 2021 +0000
+++ b/tests/usr.bin/indent/token-while_expr.0.stdout    Sat Sep 25 13:26:07 2021 +0000
@@ -1,8 +1,23 @@
-/* $NetBSD: token-while_expr.0.stdout,v 1.1 2021/03/12 00:13:06 rillig Exp $ */
+/* $NetBSD: token-while_expr.0.stdout,v 1.2 2021/09/25 13:26:07 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
  * Tests for the keyword 'while', followed by a parenthesized expression.
  */
 
-/* TODO: Add some code to be formatted. */
+int
+main(int argc, char **argv)
+{
+       int             o;
+       while ((o = getopt(argc, argv, "x:")) != -1)
+               switch (o) {
+               case 'x':
+                       do {
+                               o++;
+                       } while (o < 5);
+                       break;
+               default:
+                       usage();
+/* $ XXX: The 'return' should be in a separate line. */
+               } return 0;
+}



Home | Main Index | Thread Index | Old Index