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
This commit is contained in:
Piotr Pawel Stefaniak 2017-02-10 09:31:39 +00:00
parent e2cf2aa54d
commit 61fd3be0b0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=313544
33 changed files with 312 additions and 0 deletions

View File

@ -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 */
}

View File

@ -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 */
}

View File

@ -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
;
}

View File

@ -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
;
}

View File

@ -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 */
{
}
}

View File

@ -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 */
{
}
}

View File

@ -0,0 +1,2 @@
/* $FreeBSD$ */
-bl

View File

@ -0,0 +1,6 @@
/* $FreeBSD$ */
/* See r303499 */
void t(void) {
unsigned long x = 314UL;
float y = 3.14f;
}

View File

@ -0,0 +1,8 @@
/* $FreeBSD$ */
/* See r303499 */
void
t(void)
{
unsigned long x = 314UL;
float y = 3.14f;
}

View File

@ -0,0 +1,13 @@
/* $FreeBSD$ */
/* See r303489 */
void t(void) {
switch (1)
{
case 1: /* test */
case 2: /* test */
}
CLEANUP:
;
V: ;
U: ;
}

View File

@ -0,0 +1,14 @@
/* $FreeBSD$ */
/* See r303489 */
void
t(void)
{
switch (1) {
case 1: /* test */
case 2: /* test */
}
CLEANUP:
;
V: ;
U: ;
}

View File

@ -0,0 +1,2 @@
/* $FreeBSD$ */
-nut

View File

@ -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;

View File

@ -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;

View File

@ -0,0 +1,4 @@
/* $FreeBSD$ */
void t(void) {
int a = (double) 8;
}

View File

@ -0,0 +1,6 @@
/* $FreeBSD$ */
void
t(void)
{
int a = (double)8;
}

View File

@ -0,0 +1,2 @@
/* $FreeBSD$ */
-nsac

View File

@ -0,0 +1,5 @@
/* $FreeBSD$ */
/* See r303718 */
void t(void) {
int n = malloc(offsetof(struct s, f) + 1);
}

View File

@ -0,0 +1,7 @@
/* $FreeBSD$ */
/* See r303718 */
void
t(void)
{
int n = malloc(offsetof(struct s, f) + 1);
}

View File

@ -0,0 +1,4 @@
/* $FreeBSD$ */
void t(void) {
int a = (double) 8;
}

View File

@ -0,0 +1,6 @@
/* $FreeBSD$ */
void
t(void)
{
int a = (double) 8;
}

View File

@ -0,0 +1,2 @@
/* $FreeBSD$ */
-sac

View File

@ -0,0 +1,13 @@
/* $FreeBSD$ */
/* See r303485 */
void
t(void)
{
static const struct {
int a;
int b;
} c[] = {
{ D, E },
{ F, G }
};
}

View File

@ -0,0 +1,13 @@
/* $FreeBSD$ */
/* See r303485 */
void
t(void)
{
static const struct {
int a;
int b;
} c[] = {
{D, E},
{F, G}
};
}

View File

@ -0,0 +1,9 @@
/* $FreeBSD$ */
/* See r303599 */
#if defined(__i386__)
int a;
#elif defined(__amd64__)
int b;
#else
#error "Port me"
#endif

View File

@ -0,0 +1,9 @@
/* $FreeBSD$ */
/* See r303599 */
#if defined(__i386__)
int a;
#elif defined(__amd64__)
int b;
#else
#error "Port me"
#endif

View File

@ -0,0 +1,2 @@
/* $FreeBSD$ */
-bad

View File

@ -0,0 +1,3 @@
/* $FreeBSD$ */
/* See r303735 */
void t(a *x, b *y, c *z);

View File

@ -0,0 +1,3 @@
/* $FreeBSD$ */
/* See r303735 */
void t(a *x, b *y, c * z);

View File

@ -0,0 +1,2 @@
b
a

View File

@ -0,0 +1,2 @@
/* $FreeBSD$ */
-Utypes_from_file.list

View File

@ -0,0 +1,6 @@
/* $FreeBSD$ */
/* See r309220 */
#include <wchar.h>
wchar_t *x = L"test";
wchar_t y = L't';

View File

@ -0,0 +1,6 @@
/* $FreeBSD$ */
/* See r309220 */
#include <wchar.h>
wchar_t *x = L"test";
wchar_t y = L't';