svn commit: r313544 - head/usr.bin/indent/tests

Piotr Pawel Stefaniak pstef at FreeBSD.org
Fri Feb 10 09:31:43 UTC 2017


Author: pstef
Date: Fri Feb 10 09:31:39 2017
New Revision: 313544
URL: https://svnweb.freebsd.org/changeset/base/313544

Log:
  indent(1): add regression test cases
  
  These examples show expected behavior of indent(1). They are meant to be used
  together with a regression test mechanism, either Kyua, a Makefile or perhaps
  something else. The mechanism should in essence do this:
    indent -P${test}.pro < ${test}.0 > ${test}.0.run
  and compare ${test}.0.stdout to ${test}.0.run. If the files differ or the exit
  status isn't 0, the test failed.
  
  * ${test}.pro is an indent(1) profile: a list of options passed through a file.
    The program doesn't complain if the file doesn't exist.
  * ${test}.0 is a C source file which acts as input for indent(1). It doesn't
    have to have any particular formatting, since it's the output that matters.
  * ${test}.0.stdout contains expected output. It doesn't have to be formatted in
    Kernel Normal Form as the point of the tests is to check for regressions in
    the program and not to check that it always produces KNF.
  
  Reviewed by:	ngie
  Approved by:	pfg (mentor)
  Differential Revision:	https://reviews.freebsd.org/D9007

Added:
  head/usr.bin/indent/tests/
  head/usr.bin/indent/tests/comments.0   (contents, props changed)
  head/usr.bin/indent/tests/comments.0.stdout   (contents, props changed)
  head/usr.bin/indent/tests/declarations.0   (contents, props changed)
  head/usr.bin/indent/tests/declarations.0.stdout   (contents, props changed)
  head/usr.bin/indent/tests/elsecomment.0   (contents, props changed)
  head/usr.bin/indent/tests/elsecomment.0.stdout   (contents, props changed)
  head/usr.bin/indent/tests/elsecomment.pro   (contents, props changed)
  head/usr.bin/indent/tests/float.0   (contents, props changed)
  head/usr.bin/indent/tests/float.0.stdout   (contents, props changed)
  head/usr.bin/indent/tests/label.0   (contents, props changed)
  head/usr.bin/indent/tests/label.0.stdout   (contents, props changed)
  head/usr.bin/indent/tests/label.pro   (contents, props changed)
  head/usr.bin/indent/tests/list_head.0   (contents, props changed)
  head/usr.bin/indent/tests/list_head.0.stdout   (contents, props changed)
  head/usr.bin/indent/tests/nsac.0   (contents, props changed)
  head/usr.bin/indent/tests/nsac.0.stdout   (contents, props changed)
  head/usr.bin/indent/tests/nsac.pro   (contents, props changed)
  head/usr.bin/indent/tests/offsetof.0   (contents, props changed)
  head/usr.bin/indent/tests/offsetof.0.stdout   (contents, props changed)
  head/usr.bin/indent/tests/sac.0   (contents, props changed)
  head/usr.bin/indent/tests/sac.0.stdout   (contents, props changed)
  head/usr.bin/indent/tests/sac.pro   (contents, props changed)
  head/usr.bin/indent/tests/struct.0   (contents, props changed)
  head/usr.bin/indent/tests/struct.0.stdout   (contents, props changed)
  head/usr.bin/indent/tests/surplusbad.0   (contents, props changed)
  head/usr.bin/indent/tests/surplusbad.0.stdout   (contents, props changed)
  head/usr.bin/indent/tests/surplusbad.pro   (contents, props changed)
  head/usr.bin/indent/tests/types_from_file.0   (contents, props changed)
  head/usr.bin/indent/tests/types_from_file.0.stdout   (contents, props changed)
  head/usr.bin/indent/tests/types_from_file.list   (contents, props changed)
  head/usr.bin/indent/tests/types_from_file.pro   (contents, props changed)
  head/usr.bin/indent/tests/wchar.0   (contents, props changed)
  head/usr.bin/indent/tests/wchar.0.stdout   (contents, props changed)

Added: head/usr.bin/indent/tests/comments.0
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/usr.bin/indent/tests/comments.0	Fri Feb 10 09:31:39 2017	(r313544)
@@ -0,0 +1,25 @@
+/* $FreeBSD$ */
+/* See r303597, r303598, r309219, and r309343 */
+void t(void) {
+	/*
+	 * Old indent wrapped the URL near where this sentence ends.
+	 *
+	 * https://www.freebsd.org/cgi/man.cgi?query=indent&apropos=0&sektion=0&manpath=FreeBSD+12-current&arch=default&format=html
+	 */
+	 
+	/*
+	 * Old indent did not wrap to column 78
+	 * 
+	 * aaaaaa bbbbbb cccccc dddddd eeeeee ffffff ggggg hhhhh iiiii jjjj kk
+	 */
+	
+	/*
+	 * Old indent unnecessarily removed the star comment continuation on the next line.
+	 * 
+	 * *test*
+	 */
+	
+	/* r309219 Go through linked list, freeing from the malloced (t[-1]) address. */
+	
+	/* r309343	*/
+}

Added: head/usr.bin/indent/tests/comments.0.stdout
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/usr.bin/indent/tests/comments.0.stdout	Fri Feb 10 09:31:39 2017	(r313544)
@@ -0,0 +1,32 @@
+/* $FreeBSD$ */
+/* See r303597, r303598, r309219, and r309343 */
+void 
+t(void)
+{
+	/*
+	 * Old indent wrapped the URL near where this sentence ends.
+	 *
+	 * https://www.freebsd.org/cgi/man.cgi?query=indent&apropos=0&sektion=0&manpath=FreeBSD+12-current&arch=default&format=html
+	 */
+
+	/*
+	 * Old indent did not wrap to column 78
+	 *
+	 * aaaaaa bbbbbb cccccc dddddd eeeeee ffffff ggggg hhhhh iiiii jjjj
+	 * kk
+	 */
+
+	/*
+	 * Old indent unnecessarily removed the star comment continuation on
+	 * the next line.
+	 *
+	 * *test*
+	 */
+
+	/*
+	 * r309219 Go through linked list, freeing from the malloced (t[-1])
+	 * address.
+	 */
+
+	/* r309343	*/
+}

Added: head/usr.bin/indent/tests/declarations.0
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/usr.bin/indent/tests/declarations.0	Fri Feb 10 09:31:39 2017	(r313544)
@@ -0,0 +1,21 @@
+/* $FreeBSD$ */
+/* See r303570 */
+void t(void) {
+	int a,
+	b,
+	c;
+	int
+	*d,
+	*e,
+	*f;
+	int (*g)(),
+	(*h)(),
+	(*i)();
+	int j,
+	k,
+	l;
+	int m
+	,n
+	,o
+	;
+}

Added: head/usr.bin/indent/tests/declarations.0.stdout
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/usr.bin/indent/tests/declarations.0.stdout	Fri Feb 10 09:31:39 2017	(r313544)
@@ -0,0 +1,15 @@
+/* $FreeBSD$ */
+/* See r303570 */
+void 
+t(void)
+{
+	int		a, b, c;
+	int
+		       *d, *e, *f;
+	int 		(*g) (), (*h) (), (*i) ();
+	int		j, k, l;
+	int		m
+		       ,n
+		       ,o
+		       ;
+}

Added: head/usr.bin/indent/tests/elsecomment.0
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/usr.bin/indent/tests/elsecomment.0	Fri Feb 10 09:31:39 2017	(r313544)
@@ -0,0 +1,18 @@
+/* $FreeBSD$ */
+/* See r303484 and r309342 */
+void t(void) {
+	if (0) {
+
+	} /* Old indent would remove the following blank line */
+
+	/*
+	 * test
+	 */
+
+	if (1)
+		;
+	else /* Old indent would get very confused here */
+	{
+
+	}
+}

Added: head/usr.bin/indent/tests/elsecomment.0.stdout
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/usr.bin/indent/tests/elsecomment.0.stdout	Fri Feb 10 09:31:39 2017	(r313544)
@@ -0,0 +1,22 @@
+/* $FreeBSD$ */
+/* See r303484 and r309342 */
+void 
+t(void)
+{
+	if (0)
+	{
+
+	}			/* Old indent would remove the following
+				 * blank line */
+
+	/*
+	 * test
+	 */
+
+	if (1)
+		;
+	else			/* Old indent would get very confused here */
+	{
+
+	}
+}

Added: head/usr.bin/indent/tests/elsecomment.pro
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/usr.bin/indent/tests/elsecomment.pro	Fri Feb 10 09:31:39 2017	(r313544)
@@ -0,0 +1,2 @@
+/* $FreeBSD$ */
+-bl

Added: head/usr.bin/indent/tests/float.0
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/usr.bin/indent/tests/float.0	Fri Feb 10 09:31:39 2017	(r313544)
@@ -0,0 +1,6 @@
+/* $FreeBSD$ */
+/* See r303499 */
+void t(void) {
+	unsigned long x = 314UL;
+	float y = 3.14f;
+}

Added: head/usr.bin/indent/tests/float.0.stdout
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/usr.bin/indent/tests/float.0.stdout	Fri Feb 10 09:31:39 2017	(r313544)
@@ -0,0 +1,8 @@
+/* $FreeBSD$ */
+/* See r303499 */
+void 
+t(void)
+{
+	unsigned long	x = 314UL;
+	float		y = 3.14f;
+}

Added: head/usr.bin/indent/tests/label.0
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/usr.bin/indent/tests/label.0	Fri Feb 10 09:31:39 2017	(r313544)
@@ -0,0 +1,13 @@
+/* $FreeBSD$ */
+/* See r303489 */
+void t(void) {
+	switch (1)
+	{
+		case 1:	/* test */
+		case 2:		/* test */
+	}
+CLEANUP:
+	;
+V: ;
+U: ;
+}

Added: head/usr.bin/indent/tests/label.0.stdout
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/usr.bin/indent/tests/label.0.stdout	Fri Feb 10 09:31:39 2017	(r313544)
@@ -0,0 +1,14 @@
+/* $FreeBSD$ */
+/* See r303489 */
+void 
+t(void)
+{
+        switch (1) {
+        case 1:                 /* test */
+        case 2:                 /* test */
+        }
+CLEANUP:
+        ;
+V:      ;
+U:      ;
+}

Added: head/usr.bin/indent/tests/label.pro
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/usr.bin/indent/tests/label.pro	Fri Feb 10 09:31:39 2017	(r313544)
@@ -0,0 +1,2 @@
+/* $FreeBSD$ */
+-nut

Added: head/usr.bin/indent/tests/list_head.0
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/usr.bin/indent/tests/list_head.0	Fri Feb 10 09:31:39 2017	(r313544)
@@ -0,0 +1,16 @@
+/* $FreeBSD$ */
+/* See r309380 */
+static int
+do_execve(td, args, mac_p)
+	struct thread *td;
+	struct image_args *args;
+	struct mac *mac_p;
+{
+
+}
+
+static LIST_HEAD(, alq) ald_active;
+static int ald_shuttingdown = 0;
+struct thread *ald_thread;
+
+

Added: head/usr.bin/indent/tests/list_head.0.stdout
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/usr.bin/indent/tests/list_head.0.stdout	Fri Feb 10 09:31:39 2017	(r313544)
@@ -0,0 +1,14 @@
+/* $FreeBSD$ */
+/* See r309380 */
+static int
+do_execve(td, args, mac_p)
+	struct thread  *td;
+	struct image_args *args;
+	struct mac     *mac_p;
+{
+
+}
+
+static LIST_HEAD(, alq) ald_active;
+static int	ald_shuttingdown = 0;
+struct thread  *ald_thread;

Added: head/usr.bin/indent/tests/nsac.0
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/usr.bin/indent/tests/nsac.0	Fri Feb 10 09:31:39 2017	(r313544)
@@ -0,0 +1,4 @@
+/* $FreeBSD$ */
+void t(void) {
+	int a = (double) 8;
+}

Added: head/usr.bin/indent/tests/nsac.0.stdout
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/usr.bin/indent/tests/nsac.0.stdout	Fri Feb 10 09:31:39 2017	(r313544)
@@ -0,0 +1,6 @@
+/* $FreeBSD$ */
+void 
+t(void)
+{
+	int		a = (double)8;
+}

Added: head/usr.bin/indent/tests/nsac.pro
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/usr.bin/indent/tests/nsac.pro	Fri Feb 10 09:31:39 2017	(r313544)
@@ -0,0 +1,2 @@
+/* $FreeBSD$ */
+-nsac

Added: head/usr.bin/indent/tests/offsetof.0
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/usr.bin/indent/tests/offsetof.0	Fri Feb 10 09:31:39 2017	(r313544)
@@ -0,0 +1,5 @@
+/* $FreeBSD$ */
+/* See r303718 */
+void t(void) {
+	int n = malloc(offsetof(struct s, f) + 1);
+}

Added: head/usr.bin/indent/tests/offsetof.0.stdout
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/usr.bin/indent/tests/offsetof.0.stdout	Fri Feb 10 09:31:39 2017	(r313544)
@@ -0,0 +1,7 @@
+/* $FreeBSD$ */
+/* See r303718 */
+void 
+t(void)
+{
+	int		n = malloc(offsetof(struct s, f) + 1);
+}

Added: head/usr.bin/indent/tests/sac.0
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/usr.bin/indent/tests/sac.0	Fri Feb 10 09:31:39 2017	(r313544)
@@ -0,0 +1,4 @@
+/* $FreeBSD$ */
+void t(void) {
+	int a = (double) 8;
+}

Added: head/usr.bin/indent/tests/sac.0.stdout
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/usr.bin/indent/tests/sac.0.stdout	Fri Feb 10 09:31:39 2017	(r313544)
@@ -0,0 +1,6 @@
+/* $FreeBSD$ */
+void 
+t(void)
+{
+	int		a = (double) 8;
+}

Added: head/usr.bin/indent/tests/sac.pro
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/usr.bin/indent/tests/sac.pro	Fri Feb 10 09:31:39 2017	(r313544)
@@ -0,0 +1,2 @@
+/* $FreeBSD$ */
+-sac

Added: head/usr.bin/indent/tests/struct.0
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/usr.bin/indent/tests/struct.0	Fri Feb 10 09:31:39 2017	(r313544)
@@ -0,0 +1,13 @@
+/* $FreeBSD$ */
+/* See r303485 */
+void
+t(void)
+{
+	static const struct {
+		int	a;
+		int	b;
+	} c[] = {
+		{ D, E },
+		{ F, G }
+	};
+}

Added: head/usr.bin/indent/tests/struct.0.stdout
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/usr.bin/indent/tests/struct.0.stdout	Fri Feb 10 09:31:39 2017	(r313544)
@@ -0,0 +1,13 @@
+/* $FreeBSD$ */
+/* See r303485 */
+void
+t(void)
+{
+	static const struct {
+		int		a;
+		int		b;
+	}		c[] = {
+		{D, E},
+		{F, G}
+	};
+}

Added: head/usr.bin/indent/tests/surplusbad.0
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/usr.bin/indent/tests/surplusbad.0	Fri Feb 10 09:31:39 2017	(r313544)
@@ -0,0 +1,9 @@
+/* $FreeBSD$ */
+/* See r303599 */
+#if defined(__i386__)
+int a;
+#elif defined(__amd64__)
+int b;
+#else
+#error "Port me"
+#endif

Added: head/usr.bin/indent/tests/surplusbad.0.stdout
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/usr.bin/indent/tests/surplusbad.0.stdout	Fri Feb 10 09:31:39 2017	(r313544)
@@ -0,0 +1,9 @@
+/* $FreeBSD$ */
+/* See r303599 */
+#if defined(__i386__)
+int		a;
+#elif defined(__amd64__)
+int		b;
+#else
+#error "Port me"
+#endif

Added: head/usr.bin/indent/tests/surplusbad.pro
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/usr.bin/indent/tests/surplusbad.pro	Fri Feb 10 09:31:39 2017	(r313544)
@@ -0,0 +1,2 @@
+/* $FreeBSD$ */
+-bad

Added: head/usr.bin/indent/tests/types_from_file.0
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/usr.bin/indent/tests/types_from_file.0	Fri Feb 10 09:31:39 2017	(r313544)
@@ -0,0 +1,3 @@
+/* $FreeBSD$ */
+/* See r303735 */
+void t(a *x, b *y, c *z);

Added: head/usr.bin/indent/tests/types_from_file.0.stdout
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/usr.bin/indent/tests/types_from_file.0.stdout	Fri Feb 10 09:31:39 2017	(r313544)
@@ -0,0 +1,3 @@
+/* $FreeBSD$ */
+/* See r303735 */
+void		t(a *x, b *y, c * z);

Added: head/usr.bin/indent/tests/types_from_file.list
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/usr.bin/indent/tests/types_from_file.list	Fri Feb 10 09:31:39 2017	(r313544)
@@ -0,0 +1,2 @@
+b
+a
\ No newline at end of file

Added: head/usr.bin/indent/tests/types_from_file.pro
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/usr.bin/indent/tests/types_from_file.pro	Fri Feb 10 09:31:39 2017	(r313544)
@@ -0,0 +1,2 @@
+/* $FreeBSD$ */
+-Utypes_from_file.list

Added: head/usr.bin/indent/tests/wchar.0
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/usr.bin/indent/tests/wchar.0	Fri Feb 10 09:31:39 2017	(r313544)
@@ -0,0 +1,6 @@
+/* $FreeBSD$ */
+/* See r309220 */
+#include <wchar.h>
+
+wchar_t *x = L"test";
+wchar_t y = L't';

Added: head/usr.bin/indent/tests/wchar.0.stdout
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/usr.bin/indent/tests/wchar.0.stdout	Fri Feb 10 09:31:39 2017	(r313544)
@@ -0,0 +1,6 @@
+/* $FreeBSD$ */
+/* See r309220 */
+#include <wchar.h>
+
+wchar_t	       *x = L"test";
+wchar_t		y = L't';


More information about the svn-src-head mailing list