mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-17 15:27:36 +00:00
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:
parent
e2cf2aa54d
commit
61fd3be0b0
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=313544
25
usr.bin/indent/tests/comments.0
Normal file
25
usr.bin/indent/tests/comments.0
Normal 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 */
|
||||
}
|
32
usr.bin/indent/tests/comments.0.stdout
Normal file
32
usr.bin/indent/tests/comments.0.stdout
Normal 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 */
|
||||
}
|
21
usr.bin/indent/tests/declarations.0
Normal file
21
usr.bin/indent/tests/declarations.0
Normal 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
|
||||
;
|
||||
}
|
15
usr.bin/indent/tests/declarations.0.stdout
Normal file
15
usr.bin/indent/tests/declarations.0.stdout
Normal 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
|
||||
;
|
||||
}
|
18
usr.bin/indent/tests/elsecomment.0
Normal file
18
usr.bin/indent/tests/elsecomment.0
Normal 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 */
|
||||
{
|
||||
|
||||
}
|
||||
}
|
22
usr.bin/indent/tests/elsecomment.0.stdout
Normal file
22
usr.bin/indent/tests/elsecomment.0.stdout
Normal 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 */
|
||||
{
|
||||
|
||||
}
|
||||
}
|
2
usr.bin/indent/tests/elsecomment.pro
Normal file
2
usr.bin/indent/tests/elsecomment.pro
Normal file
@ -0,0 +1,2 @@
|
||||
/* $FreeBSD$ */
|
||||
-bl
|
6
usr.bin/indent/tests/float.0
Normal file
6
usr.bin/indent/tests/float.0
Normal file
@ -0,0 +1,6 @@
|
||||
/* $FreeBSD$ */
|
||||
/* See r303499 */
|
||||
void t(void) {
|
||||
unsigned long x = 314UL;
|
||||
float y = 3.14f;
|
||||
}
|
8
usr.bin/indent/tests/float.0.stdout
Normal file
8
usr.bin/indent/tests/float.0.stdout
Normal file
@ -0,0 +1,8 @@
|
||||
/* $FreeBSD$ */
|
||||
/* See r303499 */
|
||||
void
|
||||
t(void)
|
||||
{
|
||||
unsigned long x = 314UL;
|
||||
float y = 3.14f;
|
||||
}
|
13
usr.bin/indent/tests/label.0
Normal file
13
usr.bin/indent/tests/label.0
Normal file
@ -0,0 +1,13 @@
|
||||
/* $FreeBSD$ */
|
||||
/* See r303489 */
|
||||
void t(void) {
|
||||
switch (1)
|
||||
{
|
||||
case 1: /* test */
|
||||
case 2: /* test */
|
||||
}
|
||||
CLEANUP:
|
||||
;
|
||||
V: ;
|
||||
U: ;
|
||||
}
|
14
usr.bin/indent/tests/label.0.stdout
Normal file
14
usr.bin/indent/tests/label.0.stdout
Normal file
@ -0,0 +1,14 @@
|
||||
/* $FreeBSD$ */
|
||||
/* See r303489 */
|
||||
void
|
||||
t(void)
|
||||
{
|
||||
switch (1) {
|
||||
case 1: /* test */
|
||||
case 2: /* test */
|
||||
}
|
||||
CLEANUP:
|
||||
;
|
||||
V: ;
|
||||
U: ;
|
||||
}
|
2
usr.bin/indent/tests/label.pro
Normal file
2
usr.bin/indent/tests/label.pro
Normal file
@ -0,0 +1,2 @@
|
||||
/* $FreeBSD$ */
|
||||
-nut
|
16
usr.bin/indent/tests/list_head.0
Normal file
16
usr.bin/indent/tests/list_head.0
Normal 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;
|
||||
|
||||
|
14
usr.bin/indent/tests/list_head.0.stdout
Normal file
14
usr.bin/indent/tests/list_head.0.stdout
Normal 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;
|
4
usr.bin/indent/tests/nsac.0
Normal file
4
usr.bin/indent/tests/nsac.0
Normal file
@ -0,0 +1,4 @@
|
||||
/* $FreeBSD$ */
|
||||
void t(void) {
|
||||
int a = (double) 8;
|
||||
}
|
6
usr.bin/indent/tests/nsac.0.stdout
Normal file
6
usr.bin/indent/tests/nsac.0.stdout
Normal file
@ -0,0 +1,6 @@
|
||||
/* $FreeBSD$ */
|
||||
void
|
||||
t(void)
|
||||
{
|
||||
int a = (double)8;
|
||||
}
|
2
usr.bin/indent/tests/nsac.pro
Normal file
2
usr.bin/indent/tests/nsac.pro
Normal file
@ -0,0 +1,2 @@
|
||||
/* $FreeBSD$ */
|
||||
-nsac
|
5
usr.bin/indent/tests/offsetof.0
Normal file
5
usr.bin/indent/tests/offsetof.0
Normal file
@ -0,0 +1,5 @@
|
||||
/* $FreeBSD$ */
|
||||
/* See r303718 */
|
||||
void t(void) {
|
||||
int n = malloc(offsetof(struct s, f) + 1);
|
||||
}
|
7
usr.bin/indent/tests/offsetof.0.stdout
Normal file
7
usr.bin/indent/tests/offsetof.0.stdout
Normal file
@ -0,0 +1,7 @@
|
||||
/* $FreeBSD$ */
|
||||
/* See r303718 */
|
||||
void
|
||||
t(void)
|
||||
{
|
||||
int n = malloc(offsetof(struct s, f) + 1);
|
||||
}
|
4
usr.bin/indent/tests/sac.0
Normal file
4
usr.bin/indent/tests/sac.0
Normal file
@ -0,0 +1,4 @@
|
||||
/* $FreeBSD$ */
|
||||
void t(void) {
|
||||
int a = (double) 8;
|
||||
}
|
6
usr.bin/indent/tests/sac.0.stdout
Normal file
6
usr.bin/indent/tests/sac.0.stdout
Normal file
@ -0,0 +1,6 @@
|
||||
/* $FreeBSD$ */
|
||||
void
|
||||
t(void)
|
||||
{
|
||||
int a = (double) 8;
|
||||
}
|
2
usr.bin/indent/tests/sac.pro
Normal file
2
usr.bin/indent/tests/sac.pro
Normal file
@ -0,0 +1,2 @@
|
||||
/* $FreeBSD$ */
|
||||
-sac
|
13
usr.bin/indent/tests/struct.0
Normal file
13
usr.bin/indent/tests/struct.0
Normal file
@ -0,0 +1,13 @@
|
||||
/* $FreeBSD$ */
|
||||
/* See r303485 */
|
||||
void
|
||||
t(void)
|
||||
{
|
||||
static const struct {
|
||||
int a;
|
||||
int b;
|
||||
} c[] = {
|
||||
{ D, E },
|
||||
{ F, G }
|
||||
};
|
||||
}
|
13
usr.bin/indent/tests/struct.0.stdout
Normal file
13
usr.bin/indent/tests/struct.0.stdout
Normal file
@ -0,0 +1,13 @@
|
||||
/* $FreeBSD$ */
|
||||
/* See r303485 */
|
||||
void
|
||||
t(void)
|
||||
{
|
||||
static const struct {
|
||||
int a;
|
||||
int b;
|
||||
} c[] = {
|
||||
{D, E},
|
||||
{F, G}
|
||||
};
|
||||
}
|
9
usr.bin/indent/tests/surplusbad.0
Normal file
9
usr.bin/indent/tests/surplusbad.0
Normal file
@ -0,0 +1,9 @@
|
||||
/* $FreeBSD$ */
|
||||
/* See r303599 */
|
||||
#if defined(__i386__)
|
||||
int a;
|
||||
#elif defined(__amd64__)
|
||||
int b;
|
||||
#else
|
||||
#error "Port me"
|
||||
#endif
|
9
usr.bin/indent/tests/surplusbad.0.stdout
Normal file
9
usr.bin/indent/tests/surplusbad.0.stdout
Normal file
@ -0,0 +1,9 @@
|
||||
/* $FreeBSD$ */
|
||||
/* See r303599 */
|
||||
#if defined(__i386__)
|
||||
int a;
|
||||
#elif defined(__amd64__)
|
||||
int b;
|
||||
#else
|
||||
#error "Port me"
|
||||
#endif
|
2
usr.bin/indent/tests/surplusbad.pro
Normal file
2
usr.bin/indent/tests/surplusbad.pro
Normal file
@ -0,0 +1,2 @@
|
||||
/* $FreeBSD$ */
|
||||
-bad
|
3
usr.bin/indent/tests/types_from_file.0
Normal file
3
usr.bin/indent/tests/types_from_file.0
Normal file
@ -0,0 +1,3 @@
|
||||
/* $FreeBSD$ */
|
||||
/* See r303735 */
|
||||
void t(a *x, b *y, c *z);
|
3
usr.bin/indent/tests/types_from_file.0.stdout
Normal file
3
usr.bin/indent/tests/types_from_file.0.stdout
Normal file
@ -0,0 +1,3 @@
|
||||
/* $FreeBSD$ */
|
||||
/* See r303735 */
|
||||
void t(a *x, b *y, c * z);
|
2
usr.bin/indent/tests/types_from_file.list
Normal file
2
usr.bin/indent/tests/types_from_file.list
Normal file
@ -0,0 +1,2 @@
|
||||
b
|
||||
a
|
2
usr.bin/indent/tests/types_from_file.pro
Normal file
2
usr.bin/indent/tests/types_from_file.pro
Normal file
@ -0,0 +1,2 @@
|
||||
/* $FreeBSD$ */
|
||||
-Utypes_from_file.list
|
6
usr.bin/indent/tests/wchar.0
Normal file
6
usr.bin/indent/tests/wchar.0
Normal file
@ -0,0 +1,6 @@
|
||||
/* $FreeBSD$ */
|
||||
/* See r309220 */
|
||||
#include <wchar.h>
|
||||
|
||||
wchar_t *x = L"test";
|
||||
wchar_t y = L't';
|
6
usr.bin/indent/tests/wchar.0.stdout
Normal file
6
usr.bin/indent/tests/wchar.0.stdout
Normal file
@ -0,0 +1,6 @@
|
||||
/* $FreeBSD$ */
|
||||
/* See r309220 */
|
||||
#include <wchar.h>
|
||||
|
||||
wchar_t *x = L"test";
|
||||
wchar_t y = L't';
|
Loading…
Reference in New Issue
Block a user