Skip to content

Commit ecca13c

Browse files
committed
Remove some unnecessary comments from tests
1 parent 5f04446 commit ecca13c

18 files changed

Lines changed: 0 additions & 226 deletions

‎tests/Exception/SyntaxErrorExceptionTest.php‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ public function testExceptionPointsToTheUnexpectedToken(): void
3333
}
3434

3535
/**
36-
* Headers along with the way their failure is printed, up to the trace.
37-
*
3836
* @return iterable<non-empty-string, array{string, string}>
3937
*/
4038
public static function renderedExceptionsDataProvider(): iterable
@@ -117,10 +115,6 @@ public function testStringIsNotNamedInTheRenderedException(): void
117115
self::assertStringNotContainsString(' --> ', (string) self::catchSyntaxErrorException('int a'));
118116
}
119117

120-
/**
121-
* A stream closed after the parsing is printed with the contents the
122-
* parser has read.
123-
*/
124118
public function testExceptionOfClosedStreamIsRenderedWithTheSnippet(): void
125119
{
126120
$stream = \fopen('php://memory', 'w+b');

‎tests/Grammar/AttributesTest.php‎

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@
1313
use PHPUnit\Framework\Attributes\CoversNothing;
1414
use PHPUnit\Framework\Attributes\DataProvider;
1515

16-
/**
17-
* Checks the attributes of `resources/grammar/attributes.pp3` in every
18-
* syntax and in every position: a header is compared as the list of its
19-
* declarations printed as S-expressions, where an attribute is printed in
20-
* its own syntax, `[[gnu::aligned(8)]]`, and the attributes inside a
21-
* declarator wrap the type, `(attr _Nonnull (ptr int))`.
22-
*/
2316
#[CoversNothing]
2417
final class AttributesTest extends TestCase
2518
{
@@ -28,7 +21,6 @@ final class AttributesTest extends TestCase
2821
*/
2922
public static function syntaxesDataProvider(): iterable
3023
{
31-
// C23
3224
yield 'standard attribute' => ['[[deprecated]];', '(attributes [[deprecated]])'];
3325
yield 'prefixed attribute' => ['[[gnu::packed]];', '(attributes [[gnu::packed]])'];
3426
yield 'several attributes' => ['[[a, b::c]];', '(attributes [[a]] [[b::c]])'];
@@ -44,7 +36,6 @@ public static function syntaxesDataProvider(): iterable
4436
yield 'keyword as a prefix' => ['[[int::x]];', '(attributes [[int::x]])'];
4537
yield 'reserved keyword as a name' => ['[[fallthrough, default]];', '(attributes [[fallthrough]] [[default]])'];
4638

47-
// GCC
4839
yield 'attribute of GCC' => ['__attribute__((packed));', '(attributes __attribute__((packed)))'];
4940
yield 'short spelling of GCC' => ['__attribute((packed));', '(attributes __attribute__((packed)))'];
5041
yield 'several attributes of GCC' => [
@@ -62,15 +53,13 @@ public static function syntaxesDataProvider(): iterable
6253
'(attributes __attribute__((const)) __attribute__((__const__)))',
6354
];
6455

65-
// MSVC
6656
yield '__declspec' => ['__declspec(dllimport);', '(attributes __declspec(dllimport))'];
6757
yield '__declspec of several attributes' => [
6858
'__declspec(dllimport align(16) noreturn);',
6959
'(attributes __declspec(dllimport) __declspec(align(16)) __declspec(noreturn))',
7060
];
7161
yield 'empty __declspec' => ['__declspec();', '(attributes )'];
7262

73-
// Keywords allowed among the specifiers
7463
foreach ([
7564
'__cdecl', '__stdcall', '__fastcall', '__thiscall', '__vectorcall', '__ptr32', '__ptr64', '__w64',
7665
'__forceinline',
@@ -151,7 +140,6 @@ public function testArgumentIsAnExpressionOrTheTokens(): void
151140
*/
152141
public static function positionsDataProvider(): iterable
153142
{
154-
// Among the specifiers
155143
yield 'before the specifiers' => ['[[a]] int x;', ['(variable [[a]] int x)']];
156144
yield 'after the specifiers' => ['int [[a]] x;', ['(variable [[a]] int x)']];
157145
yield 'among the specifiers' => [
@@ -197,7 +185,6 @@ public static function positionsDataProvider(): iterable
197185
'(variable int x = (sizeof {[[a]] int}))',
198186
]];
199187

200-
// A declarator
201188
yield 'after the name' => ['int x [[a]];', ['(variable int x [[a]])']];
202189
yield 'after the name and before an array' => ['int x [[a]] [3];', ['(variable (array int 3) x [[a]])']];
203190
yield 'after the name of a function' => ['int f [[a]] (void);', ['(function (fn int (void)) f [[a]])']];
@@ -230,7 +217,6 @@ public static function positionsDataProvider(): iterable
230217
'(variable [[a]] int x [[b]] __attribute__((c)) = 1)',
231218
]];
232219

233-
// Inside a declarator
234220
yield 'after a pointer' => ['int * [[a]] p;', ['(variable (ptr int [[a]]) p)']];
235221
yield 'after a pointer and its qualifiers' => ['int * [[a]] const _Nonnull p;', [
236222
'(variable [const (ptr int [[a]] _Nonnull)] p)',
@@ -248,8 +234,6 @@ public static function positionsDataProvider(): iterable
248234
'int (*f [[a]] (void) [[b]])(int) [[c]];',
249235
['(function (fn (ptr (fn int (int) [[c]])) (void) [[b]]) f [[a]])'],
250236
];
251-
// A function wrapped into attributes is not told from an object, as
252-
// a function of a typedef name is not
253237
yield 'at the start of a parenthesized function declarator' => ['void (__stdcall f)(int);', [
254238
'(variable (attr __stdcall (fn void (int))) f)',
255239
]];
@@ -271,7 +255,6 @@ public static function positionsDataProvider(): iterable
271255
['(typedef typedef (ptr (attr __cdecl (fn void (int)))) F)'],
272256
];
273257

274-
// Parameters
275258
yield 'parameter' => ['void f([[a]] int x __attribute__((unused)), int y[2] [[b]]);', [
276259
'(function (fn void ([[a]] int x __attribute__((unused)), (array int 2 [[b]]) y)) f)',
277260
]];
@@ -299,7 +282,6 @@ public static function positionsDataProvider(): iterable
299282
'(variable int x = (sizeof (ptr (attr __cdecl (fn void (void))))))',
300283
]];
301284

302-
// Tags
303285
yield 'after struct' => ['struct [[a]] S;', ['(tag struct [[a]] S)']];
304286
yield 'after struct and before the body' => ['struct __attribute__((packed)) { int a; } s;', [
305287
'(variable struct __attribute__((packed)) _ { int a } s)',
@@ -320,7 +302,6 @@ public static function positionsDataProvider(): iterable
320302
'(tag enum E { A [[deprecated]]=1, B __attribute__((deprecated)), C })',
321303
]];
322304

323-
// Members
324305
yield 'members' => ['struct S { [[a]] int x [[b]], y __attribute__((c)); };', [
325306
'(tag struct S { [[a]] int x [[b]]; [[a]] int y __attribute__((c)) })',
326307
]];
@@ -398,10 +379,6 @@ public static function offsetsDataProvider(): iterable
398379
}
399380

400381
/**
401-
* Every attribute starts at its prefix or name, and a list of the
402-
* attributes at its first attribute or, empty in an attribute
403-
* declaration, where the declaration does.
404-
*
405382
* @param list<non-empty-string> $expected
406383
*/
407384
#[DataProvider('offsetsDataProvider')]
@@ -431,14 +408,11 @@ public static function invalidAttributesDataProvider(): iterable
431408
yield 'assembler label of a member' => ['struct S { int a __asm__("a"); };', 17, '__asm__'];
432409
yield 'two assembler labels' => ['int f(void) __asm__("a") __asm__("b");', 25, '__asm__'];
433410
yield 'attributes after struct alone' => ['struct [[a]];', 12, ';'];
434-
// GCC allows its attributes in a parenthesized declarator only at
435-
// the start of it
436411
yield 'attribute of GCC after an array in a parenthesized declarator' => [
437412
'int (*a[3] __attribute__((x)));',
438413
11,
439414
'__attribute__',
440415
];
441-
// Positions C23 has no attributes in
442416
yield 'attribute in the brackets of an array' => ['int a[[[x]] 3];', 7, '['];
443417
yield 'attribute after a parenthesized declarator' => ['int (*f) [[x]] (int);', 15, '('];
444418
yield 'attribute in a subscript' => ['int x = y[[z]];', 9, '[['];

‎tests/Grammar/DeclarationsTest.php‎

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@
1111
use PHPUnit\Framework\Attributes\CoversNothing;
1212
use PHPUnit\Framework\Attributes\DataProvider;
1313

14-
/**
15-
* Checks the external declarations of `resources/grammar/declarations.pp3`:
16-
* a header is compared as the list of its declarations printed as
17-
* S-expressions, `(variable static (ptr int) p = 0)`.
18-
*/
1914
#[CoversNothing]
2015
final class DeclarationsTest extends TestCase
2116
{
@@ -63,7 +58,6 @@ public function testDeclarationsAreParsed(string $code, array $expected): void
6358
*/
6459
public static function declaratorDeclarationsDataProvider(): iterable
6560
{
66-
// The kind of the declaration
6761
yield 'variable' => ['extern const char *const names[16];', [
6862
'(variable extern (array [const (ptr [const char])] 16) names)',
6963
]];
@@ -94,7 +88,6 @@ public static function declaratorDeclarationsDataProvider(): iterable
9488
'(variable typeof((fn int (void))) f)',
9589
]];
9690

97-
// Several declarators
9891
yield 'several declarators' => ['int a, *b, c[3];', [
9992
'(variable int a)',
10093
'(variable (ptr int) b)',
@@ -115,7 +108,6 @@ public static function declaratorDeclarationsDataProvider(): iterable
115108
'(typedef typedef (ptr void) G)',
116109
]];
117110

118-
// Tags with declarators are objects
119111
yield 'structure defined in a declaration' => ['struct S { int a; } a, *b;', [
120112
'(variable struct S { int a } a)',
121113
'(variable (ptr struct S { int a }) b)',
@@ -127,7 +119,6 @@ public static function declaratorDeclarationsDataProvider(): iterable
127119
yield 'enumeration with an underlying type' => ['enum E : int e;', ['(variable enum E : int e)']];
128120
yield 'atomic type' => ['_Atomic(int) x;', ['(variable _Atomic(int) x)']];
129121

130-
// The typedef name rule
131122
yield 'name after a modifier' => ['unsigned T;', ['(variable (unsigned _) T)']];
132123
yield 'typedef name after a modifier' => ['unsigned __int64 x;', ['(variable (unsigned __int64) x)']];
133124
yield 'typedef name after a modifier before a pointer' => ['unsigned T *p;', [
@@ -156,7 +147,6 @@ public static function declaratorDeclarationsDataProvider(): iterable
156147
yield 'name before an initializer without a type' => ['static x = 1;', ['(variable static _ x = 1)']];
157148
yield 'inferred type' => ['constexpr auto n = 1;', ['(variable constexpr auto _ n = 1)']];
158149

159-
// Initializers
160150
yield 'constant expression' => ['constexpr int N = 10;', ['(variable constexpr int N = 10)']];
161151
yield 'conditional expression' => ['int x = a ? b : c;', ['(variable int x = (? a b c))']];
162152
yield 'parenthesized comma expression' => ['int x = (1, 2);', ['(variable int x = (paren (, 1 2)))']];
@@ -182,7 +172,6 @@ public static function declaratorDeclarationsDataProvider(): iterable
182172
'(variable int c = {2})',
183173
]];
184174

185-
// Compound literals
186175
yield 'compound literal of an array' => ['int *p = (int[]){1, 2};', [
187176
'(variable (ptr int) p = (compound (array int) {1, 2}))',
188177
]];
@@ -211,7 +200,6 @@ public static function declaratorDeclarationsDataProvider(): iterable
211200
'(variable int x = (compound {static int} {1}))',
212201
]];
213202

214-
// Function definitions, the body keeps its text
215203
yield 'function definition' => ['int f(void) { return 0; }', [
216204
'(definition (fn int (void)) f { return 0; })',
217205
]];
@@ -234,7 +222,6 @@ public static function declaratorDeclarationsDataProvider(): iterable
234222
]];
235223
yield 'body after a declarator of no function' => ['int x { 1 }', ['(definition int x { 1 })']];
236224

237-
// Extensions of GCC
238225
yield 'assembler label' => ['int f(void) __asm__("_f");', ['(function (fn int (void)) f asm("_f"))']];
239226
yield 'assembler label without underscores' => ['int f(void) asm("_f");', [
240227
'(function (fn int (void)) f asm("_f"))',
@@ -259,7 +246,6 @@ public static function declaratorDeclarationsDataProvider(): iterable
259246
'(typedef typedef (long long _) T)',
260247
]];
261248

262-
// Semantically invalid, but syntactically valid
263249
yield 'typedef with an initializer' => ['typedef int x = 1;', ['(typedef typedef int x = 1)']];
264250
yield 'typedef with another storage class' => ['typedef static int x = 1;', [
265251
'(typedef typedef static int x = 1)',
@@ -331,9 +317,6 @@ public static function offsetsDataProvider(): iterable
331317
}
332318

333319
/**
334-
* Every declaration starts at its first specifier, and every node of an
335-
* initializer at its first token.
336-
*
337320
* @param list<non-empty-string> $expected
338321
*/
339322
#[DataProvider('offsetsDataProvider')]

‎tests/Grammar/DeclaratorsTest.php‎

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,6 @@
1515
use PHPUnit\Framework\Attributes\CoversNothing;
1616
use PHPUnit\Framework\Attributes\DataProvider;
1717

18-
/**
19-
* Checks the declarators and the type names of
20-
* `resources/grammar/declarators.pp3`. A declarator is checked as a member
21-
* of a structure, which needs no other node around it, and a type name as
22-
* the operand of `sizeof`. The declared type is compared as an S-expression:
23-
* `(ptr (fn int (int)))` is a pointer to a function.
24-
*/
2518
#[CoversNothing]
2619
final class DeclaratorsTest extends TestCase
2720
{
@@ -43,7 +36,6 @@ public static function membersDataProvider(): iterable
4336
yield 'atomic pointer' => ['int *_Atomic p;', '[_Atomic (ptr int)] p'];
4437
yield 'pointer to a qualified type' => ['const int *p;', '(ptr [const int]) p'];
4538

46-
// Arrays
4739
yield 'array' => ['int a[3];', '(array int 3) a'];
4840
yield 'array of arrays' => ['int a[2][3];', '(array (array int 3) 2) a'];
4941
yield 'array of pointers' => ['int *a[3];', '(array (ptr int) 3) a'];
@@ -64,7 +56,6 @@ public static function membersDataProvider(): iterable
6456
yield 'restrict without a size' => ['int a[restrict];', '(array int restrict) a'];
6557
yield 'atomic unspecified size' => ['int a[_Atomic *];', '(array int _Atomic *) a'];
6658

67-
// Functions
6859
yield 'function without parameters' => ['int f();', '(fn int ()) f'];
6960
yield 'function with void' => ['int f(void);', '(fn int (void)) f'];
7061
yield 'variadic function without parameters' => ['int f(...);', '(fn int (...)) f'];
@@ -105,14 +96,12 @@ public static function membersDataProvider(): iterable
10596
"(fn int (\xC3\x84 a, (ptr char) \xC3\x96)) f",
10697
];
10798

108-
// Bit-fields
10999
yield 'bit-field' => ['int a : 3;', 'int a:3'];
110100
yield 'unnamed bit-field' => ['int : 3;', 'int _:3'];
111101
yield 'pointer bit-field' => ['int *a : 3;', '(ptr int) a:3'];
112102
yield 'parenthesized bit-field name' => ['int (a) : 3;', 'int a:3'];
113103
yield 'unnamed bit-field after a pointer' => ['int *a, : 3;', '(ptr int) a int _:3'];
114104

115-
// Semantically invalid, but syntactically valid
116105
yield 'function returning an array' => ['int f()[3];', '(fn (array int 3) ()) f'];
117106
yield 'function returning a function' => ['int f()(int);', '(fn (fn int (int)) ()) f'];
118107
yield 'array of functions' => ['int a[3](int);', '(array (fn int (int)) 3) a'];
@@ -198,8 +187,6 @@ public static function specifiersWithTypeNamesDataProvider(): iterable
198187
yield 'atomic type specifier' => ['_Atomic(int (*)(void));', '(type _Atomic((ptr (fn int (void)))))'];
199188
yield 'typeof of an array without a size' => ['typeof(T[]);', '(type typeof((array T)))'];
200189

201-
// A type name that reads as an expression is the expression, where
202-
// the expression is allowed too
203190
yield 'typeof of a subscript' => ['typeof(T[3]);', '(type typeof(([] T 3)))'];
204191
yield 'typeof of a product' => ['typeof(a * (b));', '(type typeof((* a (paren b))))'];
205192
yield 'typeof of a call without arguments' => ['typeof(f());', '(type typeof((call f)))'];
@@ -212,9 +199,6 @@ public static function specifiersWithTypeNamesDataProvider(): iterable
212199
yield 'atomic array of a typedef name' => ['_Atomic(T[3]);', '(type _Atomic((array T 3)))'];
213200
}
214201

215-
/**
216-
* Every specifier with a type name accepts an abstract declarator.
217-
*/
218202
#[DataProvider('specifiersWithTypeNamesDataProvider')]
219203
public function testTypeNameOfSpecifierIsParsed(string $code, string $expected): void
220204
{
@@ -246,10 +230,6 @@ public static function typeNamesReadAsExpressionsDataProvider(): iterable
246230
yield 'alignof of an array of a typedef name' => ['alignof(T[3])', '(alignof (paren ([] T 3)))'];
247231
}
248232

249-
/**
250-
* A type name that starts with an identifier and reads as an expression
251-
* as well is read as the expression, where the expression is allowed.
252-
*/
253233
#[DataProvider('typeNamesReadAsExpressionsDataProvider')]
254234
public function testTypeNameThatReadsAsAnExpressionIsReadAsTheExpression(string $code, string $expected): void
255235
{
@@ -280,10 +260,6 @@ public static function typeNamesReadAsTypesDataProvider(): iterable
280260
yield 'atomic array of a typedef name' => ['sizeof(_Atomic(T[3]))', '(sizeof _Atomic((array T 3)))'];
281261
}
282262

283-
/**
284-
* A type name that cannot be an expression stays a type name, and so
285-
* does any type name where only a type name is allowed.
286-
*/
287263
#[DataProvider('typeNamesReadAsTypesDataProvider')]
288264
public function testTypeNameThatCannotBeAnExpressionIsReadAsTheType(string $code, string $expected): void
289265
{
@@ -335,9 +311,6 @@ public static function offsetsDataProvider(): iterable
335311
}
336312

337313
/**
338-
* A type built by a declarator starts at its own token: the asterisk,
339-
* the bracket or the parenthesis.
340-
*
341314
* @param list<non-empty-string> $expected
342315
*/
343316
#[DataProvider('offsetsDataProvider')]
@@ -375,8 +348,6 @@ public static function invalidDeclaratorsDataProvider(): iterable
375348
yield 'abstract bit-field' => ['struct S { int * : 3; };', 17, ':'];
376349
yield 'name in a type name' => ['static_assert(sizeof(int x));', 25, 'x'];
377350

378-
// A type name that reads as an expression is the expression in a
379-
// cast, and the cast to an array or a function is lost with it
380351
yield 'cast to an array of a typedef name' => ['static_assert((T[3])x);', 20, 'x'];
381352
yield 'cast to a function of a typedef name' => ['static_assert((T *(U))x);', 22, 'x'];
382353
}

0 commit comments

Comments
 (0)