packages/sql-faker/tests/Unit/Compiler/Bison/Ast/BisonPrecedenceDeclarationTest.php
1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\SqlFaker\Compiler\Bison\Ast;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\TestCase;
9use SqlFaker\Compiler\Bison\Ast\BisonPrecedenceDeclaration;
10
11#[CoversClass(BisonPrecedenceDeclaration::class)]
12final class BisonPrecedenceDeclarationTest extends TestCase
13{
14 public function testAssociativity(): void
15 {
16 $decl = new BisonPrecedenceDeclaration('left', null, ['OR_SYM']);
17
18 self::assertSame('left', $decl->associativity);
19 }
20
21 public function testTypeTag(): void
22 {
23 $decl = new BisonPrecedenceDeclaration('right', '<type>', ['UMINUS']);
24
25 self::assertSame('<type>', $decl->typeTag);
26 }
27
28 public function testTypeTagNull(): void
29 {
30 $decl = new BisonPrecedenceDeclaration('nonassoc', null, []);
31
32 self::assertNull($decl->typeTag);
33 }
34
35 public function testSymbols(): void
36 {
37 $decl = new BisonPrecedenceDeclaration('left', null, ['OR_SYM', 'OR2_SYM']);
38
39 self::assertSame(['OR_SYM', 'OR2_SYM'], $decl->symbols);
40 }
41}
42